[[project @ 2002-07-03 08:53:50 by simonpj]
simonpj**20020703085350
Reorder sections of type-system extensions
] {
hunk ./ghc/docs/users_guide/glasgow_exts.sgml 235
+
+Explicitly-kinded quantification
+
+
+Haskell infers the kind of each type variable. Sometimes it is nice to be able
+to give the kind explicitly as (machine-checked) documentation,
+just as it is nice to give a type signature for a function. On some occasions,
+it is essential to do so. For example, in his paper "Restricted Data Types in Haskell" (Haskell Workshop 1999)
+John Hughes had to define the data type:
+
+ data Set cxt a = Set [a]
+ | Unused (cxt a -> ())
+
+The only use for the Unused constructor was to force the correct
+kind for the type variable cxt.
+
+
+GHC now instead allows you to specify the kind of a type variable directly, wherever
+a type variable is explicitly bound. Namely:
+
+data declarations:
+
+ data Set (cxt :: * -> *) a = Set [a]
+
+type declarations:
+
+ type T (f :: * -> *) = f Int
+
+class declarations:
+
+ class (Eq a) => C (f :: * -> *) a where ...
+
+forall's in type signatures:
+
+ f :: forall (cxt :: * -> *). Set cxt Int
+
+
+
+
+
+The parentheses are required. Some of the spaces are required too, to
+separate the lexemes. If you write (f::*->*) you
+will get a parse error, because "::*->*" is a
+single lexeme in Haskell.
+
+
+
+As part of the same extension, you can put kind annotations in types
+as well. Thus:
+
+ f :: (Int :: *) -> Int
+ g :: forall a. a -> (a :: *)
+
+The syntax is
+
+ atype ::= '(' ctype '::' kind ')
+
+The parentheses are required.
+
+
+
+
hunk ./ghc/docs/users_guide/glasgow_exts.sgml 2284
-
-Explicitly-kinded quantification
-
-
-Haskell infers the kind of each type variable. Sometimes it is nice to be able
-to give the kind explicitly as (machine-checked) documentation,
-just as it is nice to give a type signature for a function. On some occasions,
-it is essential to do so. For example, in his paper "Restricted Data Types in Haskell" (Haskell Workshop 1999)
-John Hughes had to define the data type:
-
- data Set cxt a = Set [a]
- | Unused (cxt a -> ())
-
-The only use for the Unused constructor was to force the correct
-kind for the type variable cxt.
-
-
-GHC now instead allows you to specify the kind of a type variable directly, wherever
-a type variable is explicitly bound. Namely:
-
-data declarations:
-
- data Set (cxt :: * -> *) a = Set [a]
-
-type declarations:
-
- type T (f :: * -> *) = f Int
-
-class declarations:
-
- class (Eq a) => C (f :: * -> *) a where ...
-
-forall's in type signatures:
-
- f :: forall (cxt :: * -> *). Set cxt Int
-
-
-
-
-
-The parentheses are required. Some of the spaces are required too, to
-separate the lexemes. If you write (f::*->*) you
-will get a parse error, because "::*->*" is a
-single lexeme in Haskell.
-
-
-
-As part of the same extension, you can put kind annotations in types
-as well. Thus:
-
- f :: (Int :: *) -> Int
- g :: forall a. a -> (a :: *)
-
-The syntax is
-
- atype ::= '(' ctype '::' kind ')
-
-The parentheses are required.
-
-
}