[[project @ 2005-02-25 17:06:43 by simonpj]
simonpj**20050225170643
improve docs for scoped type vars
] {
hunk ./ghc/docs/users_guide/glasgow_exts.xml 2676
-A pattern type signature can introduce a scoped type
-variable. For example
-
-
-
-
+A lexically scoped type variable can be bound by:
+
+A declaration type signature ()
+A pattern type signature ()
+A result type signature ()
+
+For example:
hunk ./ghc/docs/users_guide/glasgow_exts.xml 2689
-
-
-
-
hunk ./ghc/docs/users_guide/glasgow_exts.xml 2696
- Pattern type signatures are completely orthogonal to ordinary, separate
-type signatures. The two can be used independently or together.
hunk ./ghc/docs/users_guide/glasgow_exts.xml 2718
-What a pattern type signature means
+What a scoped type variable means
hunk ./ghc/docs/users_guide/glasgow_exts.xml 2720
-A type variable brought into scope by a pattern type signature is simply
-the name for a type. The restriction they express is that all occurrences
+A lexically-scoped type variable is simply
+the name for a type. The restriction it expresses is that all occurrences
hunk ./ghc/docs/users_guide/glasgow_exts.xml 2891
-
+
+Declaration type signatures
+A declaration type signature that has explicit
+quantification (using forall) brings into scope the
+explicitly-quantified
+type variables, in the definition of the named function(s). For example:
+
+ f :: forall a. [a] -> [a]
+ f (x:xs) = xs ++ [ x :: a ]
+
+The "forall a" brings "a" into scope in
+the definition of "f".
+
+This only happens if the quantification in f's type
+signature is explicit. For example:
+
+ g :: [a] -> [a]
+ g (x:xs) = xs ++ [ x :: a ]
+
+This program will be rejected, because "a" does not scope
+over the definition of "f", so "x::a"
+means "x::forall a. a" by Haskell's usual implicit
+quantification rules.
+
+
+
+
hunk ./ghc/docs/users_guide/glasgow_exts.xml 3034
+Pattern type signatures are completely orthogonal to ordinary, separate
+type signatures. The two can be used independently or together.
hunk ./ghc/docs/users_guide/glasgow_exts.xml 3039
-
+
}