X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fusers_guide%2Fglasgow_exts.xml;h=ac10e2128ba42a26160e183af04831ba3b296599;hb=25ebbb764146f4c4634720bb285c3611e95cc951;hp=8bca4857c5840fd55b658d0215077c8c94b2516d;hpb=f7c548fd652b99e7e2e4069ecd7ce2a5821d33ae;p=ghc-hetmet.git
diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml
index 8bca485..ac10e21 100644
--- a/docs/users_guide/glasgow_exts.xml
+++ b/docs/users_guide/glasgow_exts.xml
@@ -277,8 +277,6 @@ documentation describes all the libraries that come with GHC.
-
-
Unboxed types and primitive operations
@@ -383,6 +381,13 @@ worse, the unboxed value might be larger than a pointer
(Double# for instance).
+ You cannot define a newtype whose representation type
+(the argument type of the data constructor) is an unboxed type. Thus,
+this is illegal:
+
+ newtype A = MkA Int#
+
+ You cannot bind a variable with an unboxed type
in a top-level binding.
@@ -552,14 +557,11 @@ import qualified Control.Monad.ST.Strict as ST
linkend="search-path"/>.
GHC comes with a large collection of libraries arranged
- hierarchically; see the accompanying library documentation.
- There is an ongoing project to create and maintain a stable set
- of core libraries used by several Haskell
- compilers, and the libraries that GHC comes with represent the
- current status of that project. For more details, see Haskell
- Libraries.
-
+ hierarchically; see the accompanying library
+ documentation. More libraries to install are available
+ from HackageDB.
@@ -964,7 +966,7 @@ a data type with no constructors. For example:
Syntactically, the declaration lacks the "= constrs" part. The
type can be parameterised over types of any kind, but if the kind is
not * then an explicit kind annotation must be used
-(see ).
+(see ).
Such data types have only one value, namely bottom.
Nevertheless, they can be useful when defining "phantom types".
@@ -1226,7 +1228,7 @@ that collection of packages in a uniform manner. You can express
quite a bit of object-oriented-like programming this way.
-
+Why existential?
@@ -1249,9 +1251,9 @@ But Haskell programmers can safely think of the ordinary
adding a new existential quantification construct.
-
+
-
+Type classes
@@ -1311,9 +1313,9 @@ Notice the way that the syntax fits smoothly with that used for
universal quantification earlier.
-
+
-
+Record Constructors
@@ -1330,7 +1332,7 @@ data Counter a = forall self. NewCounter
Here tag is a public field, with a well-typed selector
function tag :: Counter a -> a. The self
type is hidden from the outside; any attempt to apply _this,
-_inc or _output as functions will raise a
+_inc or _display as functions will raise a
compile-time error. In other words, GHC defines a record selector function
only for fields whose type does not mention the existentially-quantified variables.
(This example used an underscore in the fields for which record selectors
@@ -1376,10 +1378,10 @@ setTag obj t = obj{ tag = t }
-
+
-
+Restrictions
@@ -1530,7 +1532,7 @@ declarations. Define your own instances!
-
+
@@ -2546,7 +2548,7 @@ the context and head of the instance declaration can each consist of arbitrary
following rules:
-For each assertion in the context:
+The Paterson Conditions: for each assertion in the context
No type variable has more occurrences in the assertion than in the headThe assertion has fewer constructors and variables (taken together
@@ -2554,7 +2556,7 @@ For each assertion in the context:
-The coverage condition. For each functional dependency,
+The Coverage Condition. For each functional dependency,
tvsleft->tvsright, of the class,
every type variable in
@@ -2566,11 +2568,15 @@ corresponding type in the instance declaration.
These restrictions ensure that context reduction terminates: each reduction
step makes the problem smaller by at least one
-constructor. For example, the following would make the type checker
-loop if it wasn't excluded:
-
- instance C a => C a where ...
-
+constructor. Both the Paterson Conditions and the Coverage Condition are lifted
+if you give the
+flag ().
+You can find lots of background material about the reason for these
+restrictions in the paper
+Understanding functional dependencies via Constraint Handling Rules.
+
+
For example, these are OK:
instance C Int [a] -- Multiple parameters
@@ -2622,11 +2628,6 @@ something more specific does not:
op = ... -- Default
-You can find lots of background material about the reason for these
-restrictions in the paper
-Understanding functional dependencies via Constraint Handling Rules.
-
@@ -2691,8 +2692,8 @@ makes instance inference go into a loop, because it requires the constraint
Nevertheless, GHC allows you to experiment with more liberal rules. If you use
the experimental flag
-fallow-undecidable-instances
-option, you can use arbitrary
-types in both an instance context and instance head. Termination is ensured by having a
+option, both the Paterson Conditions and the Coverage Condition
+(described in ) are lifted. Termination is ensured by having a
fixed-depth recursion stack. If you exceed the stack depth you get a
sort of backtrace, and the opportunity to increase the stack depth
with N.
@@ -3372,7 +3373,7 @@ and you'd be right. That is why they are an experimental feature.
================ END OF Linear Implicit Parameters commented out -->
-
+Explicitly-kinded quantification
@@ -3492,7 +3493,6 @@ including an operational type class context, is legal:
On the left or right (see f4, for example)
of a function arrow
- On the right of a function arrow (see ) As the argument of a constructor, or type of a field, in a data type declaration. For
example, any of the f1,f2,f3,g1,g2 above would be valid
field type signatures.
@@ -4087,15 +4087,39 @@ The class IsString is defined as:
class IsString a where
fromString :: String -> a
-And the only predefined instance is the obvious one to make strings work as usual:
+The only predefined instance is the obvious one to make strings work as usual:
instance IsString [Char] where
fromString cs = cs
+The class IsString is not in scope by default. If you want to mention
+it explicitly (for exmaple, to give an instance declaration for it), you can import it
+from module GHC.Exts.
+
+
+Haskell's defaulting mechanism is extended to cover string literals, when is specified.
+Specifically:
+
+
+Each type in a default declaration must be an
+instance of Numor of IsString.
+
+
+
+The standard defaulting rule (Haskell Report, Section 4.3.4)
+is extended thus: defaulting applies when all the unresolved constraints involve standard classes
+orIsString; and at least one is a numeric class
+orIsString.
+
+
A small example:
+module Main where
+
+import GHC.Exts( IsString(..) )
+
newtype MyString = MyString String deriving (Eq, Show)
instance IsString MyString where
fromString = MyString
@@ -4115,6 +4139,33 @@ to work since it gets translated into an equality comparison.
+
+Type families
+
+
+
+GHC supports the definition of type families indexed by types. They may be
+seen as an extension of Haskell 98's class-based overloading of values to
+types. When type families are declared in classes, they are also known as
+associated types.
+
+
+There are two forms of type families: data families and type synonym families.
+Currently, only the former are fully implemented, while we are still working
+on the latter. As a result, the specification of the language extension is
+also still to some degree in flux. Hence, a more detailed description of
+the language extension and its use is currently available
+from the Haskell
+wiki page on type families. The material will be moved to this user's
+guide when it has stabilised.
+
+
+Type families are enabled by the flag .
+
+
+
+
+
@@ -4853,7 +4904,7 @@ Because the preprocessor targets Haskell (rather than Core),
-
+Bang patterns
Bang patterns
@@ -4868,7 +4919,7 @@ than the material below.
Bang patterns are enabled by the flag .
-
+Informal description of bang patterns
@@ -4923,7 +4974,7 @@ is part of the syntax of let bindings.
-
+Syntax and semantics
@@ -4997,7 +5048,7 @@ a module.
-
+Assertions
Assertions