X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fusers_guide%2Fglasgow_exts.xml;h=ea313904faf870ca28e70554d6ea3e1ad42e717e;hb=e5b79a6988880d8757634683eefe2f03e45cdfc6;hp=5d1b5cf5f053bf3a3435740f51ee0a7a1c88d3f0;hpb=432b9c9322181a3644083e3c19b7e240d90659e7;p=ghc-hetmet.git
diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml
index 5d1b5cf..ea31390 100644
--- a/docs/users_guide/glasgow_exts.xml
+++ b/docs/users_guide/glasgow_exts.xml
@@ -109,7 +109,7 @@ While you really can use this stuff to write fast code,
All these primitive data types and operations are exported by the
library GHC.Prim, for which there is
-detailed online documentation.
+detailed online documentation.
(This documentation is generated from the file compiler/prelude/primops.txt.pp.)
@@ -840,6 +840,19 @@ y) will not be coalesced.
+
+
+
+n+k patterns
+
+
+
+n+k pattern support is enabled by default. To disable
+it, you can use the flag.
+
+
+
+
@@ -874,7 +887,7 @@ As you can guess justOnes will evaluate to Just [1,1
-The Control.Monad.Fix library introduces the MonadFix class. It's definition is:
+The Control.Monad.Fix library introduces the MonadFix class. Its definition is:
class Monad m => MonadFix m where
@@ -1001,7 +1014,7 @@ This name is not supported by GHC.
Generalised list comprehensions are a further enhancement to the
- list comprehension syntatic sugar to allow operations such as sorting
+ list comprehension syntactic sugar to allow operations such as sorting
and grouping which are familiar from SQL. They are fully described in the
paper
Comprehensive comprehensions: comprehensions with "order by" and "group by",
@@ -1042,7 +1055,7 @@ then f
This statement requires that f have the type
- forall a. [a] -> [a]. You can see an example of it's use in the
+ forall a. [a] -> [a]. You can see an example of its use in the
motivating example, as this form is used to apply take 5.
@@ -1269,6 +1282,44 @@ definitions; you must define such a function in prefix form.
+
+Tuple sections
+
+
+ The flag enables Python-style partially applied
+ tuple constructors. For example, the following program
+
+ (, True)
+
+ is considered to be an alternative notation for the more unwieldy alternative
+
+ \x -> (x, True)
+
+You can omit any combination of arguments to the tuple, as in the following
+
+ (, "I", , , "Love", , 1337)
+
+which translates to
+
+ \a b c d -> (a, "I", b, c, "Love", d, 1337)
+
+
+
+
+ If you have unboxed tuples enabled, tuple sections
+ will also be available for them, like so
+
+ (# , True #)
+
+Because there is no unboxed unit tuple, the following expression
+
+ (# #)
+
+continues to stand for the unboxed singleton tuple data constructor.
+
+
+
+
Record field disambiguation
@@ -2579,7 +2630,7 @@ constructor).
-It's is permitted to declare an ordinary algebraic data type using GADT-style syntax.
+It is permitted to declare an ordinary algebraic data type using GADT-style syntax.
What makes a GADT into a GADT is not the syntax, but rather the presence of data constructors
whose result type is not just T a b.
@@ -2691,16 +2742,22 @@ GHC now allows stand-alone deriving declarations, enabled by
The syntax is identical to that of an ordinary instance declaration apart from (a) the keyword
deriving, and (b) the absence of the where part.
-You must supply a context (in the example the context is (Eq a)),
+Note the following points:
+
+
+You must supply an explicit context (in the example the context is (Eq a)),
exactly as you would in an ordinary instance declaration.
-(In contrast the context is inferred in a deriving clause
-attached to a data type declaration.)
+(In contrast, in a deriving clause
+attached to a data type declaration, the context is inferred.)
+
+
A deriving instance declaration
must obey the same rules concerning form and termination as ordinary instance declarations,
controlled by the same flags; see .
-
-
+
+
+
Unlike a deriving
declaration attached to a data declaration, the instance can be more specific
than the data type (assuming you also use
@@ -2714,8 +2771,31 @@ for example
This will generate a derived instance for (Foo [a]) and (Foo (Maybe a)),
but other types such as (Foo (Int,Bool)) will not be an instance of Eq.
+
+
+
+Unlike a deriving
+declaration attached to a data declaration,
+GHC does not restrict the form of the data type. Instead, GHC simply generates the appropriate
+boilerplate code for the specified class, and typechecks it. If there is a type error, it is
+your problem. (GHC will show you the offending code if it has a type error.)
+The merit of this is that you can derive instances for GADTs and other exotic
+data types, providing only that the boilerplate code does indeed typecheck. For example:
+
+ data T a where
+ T1 :: T Int
+ T2 :: T Bool
+
+ deriving instance Show (T a)
+
+In this example, you cannot say ... deriving( Show ) on the
+data type declaration for T,
+because T is a GADT, but you can generate
+the instance declaration using stand-alone deriving.
+
+The stand-alone syntax is generalised for newtypes in exactly the same
way that ordinary deriving clauses are generalised ().
For example:
@@ -2726,7 +2806,8 @@ For example:
GHC always treats the last parameter of the instance
(Foo in this example) as the type whose instance is being derived.
-
+
+
@@ -4298,7 +4379,7 @@ type family Elem c
example, consider the following declaration:
type family F a b :: * -> * -- F's arity is 2,
- -- although it's overall kind is * -> * -> * -> *
+ -- although its overall kind is * -> * -> * -> *
Given this declaration the following are examples of well-formed and
malformed types: