X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fdocs%2Fusers_guide%2Fglasgow_exts.sgml;h=025a92387e1e38ef3b2b409def984e1a02f9689c;hb=9a9feb62db17daf7f2566395f719c2aecec5feb0;hp=af0a768046b18dd2a17e70e319b58a056328d943;hpb=ed53c6775a6b81509fc8955d066ee7d0197eb29c;p=ghc-hetmet.git diff --git a/ghc/docs/users_guide/glasgow_exts.sgml b/ghc/docs/users_guide/glasgow_exts.sgml index af0a768..025a923 100644 --- a/ghc/docs/users_guide/glasgow_exts.sgml +++ b/ghc/docs/users_guide/glasgow_exts.sgml @@ -1597,9 +1597,9 @@ declarations instance context2 => C type2 where ... +"overlap" if type1 and type2 unify. -"overlap" if type1 and type2 unify - + However, if you give the command line option -fallow-overlapping-instances option then overlapping instance declarations are permitted. @@ -3105,17 +3105,24 @@ where S is a type constructor, - t1...tk are types, + The t1...tk are types, - vk+1...vn are type variables which do not occur in any of + The vk+1...vn are type variables which do not occur in any of the ti, and - the ci are partial applications of + The ci are partial applications of classes of the form C t1'...tj', where the arity of C is exactly j+1. That is, C lacks exactly one type argument. + + None of the ci is Read, Show, + Typeable, or Data. These classes + should not "look through" the type or its constructor. You can still + derive these classes for a newtype, but it happens in the usual way, not + via this new mechanism. + Then, for each ci, the derived instance declaration is: @@ -3781,7 +3788,7 @@ a new form keyword. Although only GHC implements arrow notation directly, there is also a preprocessor (available from the -arrows web page>) +arrows web page) that translates arrow notation into Haskell 98 for use with other Haskell systems. You would still want to check arrow programs with GHC; @@ -3936,7 +3943,7 @@ Assertion failures can be caught, see the documentation for the The DEPRECATED pragma lets you specify that a particular function, class, or type, is deprecated. There are two - forms. + forms. @@ -3961,7 +3968,15 @@ Assertion failures can be caught, see the documentation for the message. - + Any use of the deprecated item, or of anything from a deprecated + module, will be flagged with an appropriate message. However, + deprecations are not reported for + (a) uses of a deprecated function within its defining module, and + (b) uses of a deprecated function in an export list. + The latter reduces spurious complaints within a library + in which one module gathers together and re-exports + the exports of several others. + You can suppress the warnings with the flag . @@ -4247,7 +4262,71 @@ of the pragma. - + + UNPACK pragma + + UNPACK + + The UNPACK indicates to the compiler + that it should unpack the contents of a constructor field into + the constructor itself, removing a level of indirection. For + example: + + +data T = T {-# UNPACK #-} !Float + {-# UNPACK #-} !Float + + + will create a constructor T containing + two unboxed floats. This may not always be an optimisation: if + the T constructor is scrutinised and the + floats passed to a non-strict function for example, they will + have to be reboxed (this is done automatically by the + compiler). + + Unpacking constructor fields should only be used in + conjunction with , in order to expose + unfoldings to the compiler so the reboxing can be removed as + often as possible. For example: + + +f :: T -> Float +f (T f1 f2) = f1 + f2 + + + The compiler will avoid reboxing f1 + and f2 by inlining + + on floats, but only when is on. + + Any single-constructor data is eligible for unpacking; for + example + + +data T = T {-# UNPACK #-} !(Int,Int) + + + will store the two Ints directly in the + T constructor, by flattening the pair. + Multi-level unpacking is also supported: + + +data T = T {-# UNPACK #-} !S +data S = S {-# UNPACK #-} !Int {-# UNPACK #-} !Int + + + will store two unboxed Int#s + directly in the T constructor. The + unpacker can see through newtypes, too. + + If a field cannot be unpacked, you will not get a warning, + so it might be an idea to check the generated code with + . + + See also the flag, + which essentially has the effect of adding + {-# UNPACK #-} to every strict + constructor field. +