X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fusers_guide%2Fglasgow_exts.xml;h=b2daa16709225747cb102764c71ff752a145977b;hb=9006dbf097ef7acd612a2c4463fe942165478a79;hp=f8ea3c72645da34b71d9bbea37386246c21f3dc6;hpb=90bbfd9f775c1018d6d5c4a9df7c3b277bb89e3d;p=ghc-hetmet.git
diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml
index f8ea3c7..b2daa16 100644
--- a/docs/users_guide/glasgow_exts.xml
+++ b/docs/users_guide/glasgow_exts.xml
@@ -106,9 +106,7 @@ documentation describes all the libraries that come with GHC.
This option enables the language extension defined in the
- Haskell 98 Foreign Function Interface Addendum plus deprecated
- syntax of previous versions of the FFI for backwards
- compatibility.
+ Haskell 98 Foreign Function Interface Addendum.
New reserved words: foreign.
@@ -116,7 +114,7 @@ documentation describes all the libraries that come with GHC.
- ,:
+ ,:
These two flags control how generalisation is done.
@@ -3301,6 +3299,7 @@ changing the program.
A lexically scoped type variable can be bound by:
A declaration type signature ()
+An expression type signature ()A pattern type signature ()Class and instance declarations ()
@@ -3352,6 +3351,23 @@ quantification rules.
+
+Expression type signatures
+
+An expression type signature that has explicit
+quantification (using forall) brings into scope the
+explicitly-quantified
+type variables, in the annotated expression. For example:
+
+ f = runST ( (op >>= \(x :: STRef s Int) -> g x) :: forall s. ST s Bool )
+
+Here, the type signature forall a. ST s Bool brings the
+type variable s into scope, in the annotated expression
+(op >>= \(x :: STRef s Int) -> g x).
+
+
+
+
Pattern type signatures
@@ -3709,6 +3725,33 @@ the standard method is used or the one described here.)
+
+Stand-alone deriving declarations
+
+
+GHC now allows stand-alone deriving declarations:
+
+
+
+ data Foo = Bar Int | Baz String
+
+ deriving Eq for Foo
+
+
+Deriving instances of multi-parameter type classes for newtypes is
+also allowed:
+
+
+ newtype Foo a = MkFoo (State Int a)
+
+ deriving (MonadState Int) for Foo
+
+
+
+
+
+
+
Generalised typing of mutually recursive bindings
@@ -3778,9 +3821,9 @@ pattern binding must have the same context. For example, this is fine:
-Generalised Algebraic Data Types
+Generalised Algebraic Data Types (GADTs)
-Generalised Algebraic Data Types (GADTs) generalise ordinary algebraic data types by allowing you
+Generalised Algebraic Data Types generalise ordinary algebraic data types by allowing you
to give the type signatures of constructors explicitly. For example:
data Term a where
@@ -3801,7 +3844,12 @@ for these Terms:
eval (If b e1 e2) = if eval b then eval e1 else eval e2
eval (Pair e1 e2) = (eval e1, eval e2)
-These and many other examples are given in papers by Hongwei Xi, and Tim Sheard.
+These and many other examples are given in papers by Hongwei Xi, and
+Tim Sheard. There is a longer introduction
+on the wiki,
+and Ralf Hinze's
+Fun with phantom types also has a number of examples. Note that papers
+may use different notation to that implemented in GHC.
The rest of this section outlines the extensions to GHC that support GADTs.
@@ -4759,7 +4807,7 @@ f !x = 3
Is this a definition of the infix function "(!)",
or of the "f" with a bang pattern? GHC resolves this
-ambiguity inf favour of the latter. If you want to define
+ambiguity in favour of the latter. If you want to define
(!) with bang-patterns enabled, you have to do so using
prefix notation:
@@ -6082,6 +6130,22 @@ r) ->
described in this section. All are exported by
GHC.Exts.
+The seq function
+
+The function seq is as described in the Haskell98 Report.
+
+ seq :: a -> b -> b
+
+It evaluates its first argument to head normal form, and then returns its
+second argument as the result. The reason that it is documented here is
+that, despite seq's polymorphism, its
+second argument can have an unboxed type, or
+can be an unboxed tuple; for example (seq x 4#)
+or (seq x (# p,q #)). This requires b
+to be instantiated to an unboxed type, which is not usually allowed.
+
+
+
The inline function
The inline function is somewhat experimental.
@@ -6140,6 +6204,11 @@ If lazy were not lazy, par would
look strict in y which would defeat the whole
purpose of par.
+
+Like seq, the argument of lazy can have
+an unboxed type.
+
+
The unsafeCoerce# function
@@ -6155,7 +6224,14 @@ It is generally used when you want to write a program that you know is
well-typed, but where Haskell's type system is not expressive enough to prove
that it is well typed.
+
+The argument to unsafeCoerce# can have unboxed types,
+although extremely bad things will happen if you coerce a boxed type
+to an unboxed type.
+
+
+