Changes between Version 1 and Version 2 of ScopedTypeVariables


Ignore:
Timestamp:
Nov 29, 2005 2:18:57 PM (8 years ago)
Author:
ross@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ScopedTypeVariables

    v1 v2  
    66== Brief Explanation == 
    77 
     8Type annotations, which Haskell 98 allows in expressions, are also allowed in patterns and (currently in GHC only) in result type signatures, attached to the left side of a function definition.  New type variables in these annotations scope over the function body, permitting locally defined variables to be given signatures in situations where it would be impossible in Haskell 98, e.g. 
     9{{{ 
     10sortImage :: Ord b => (a -> b) -> [a] -> [a] 
     11sortImage (f::a->b) = sortBy cmp 
     12  where cmp :: a -> a -> Ordering 
     13        cmp x y = compare (f x) (f y) 
     14}}} 
     15 
    816== References == 
    9  * [http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#scoped-type-variables] GHC documentation. 
     17 * [http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#scoped-type-variables GHC documentation] 
     18 * [http://cvs.haskell.org/Hugs/pages/users_guide/type-annotations.html Hugs documentation] 
     19 
     20Note that although GHC and Hugs use the same syntax, the meaning of type variables is quite different, and there are other differences too. 
    1021 
    1122== Pros ==