Changes between Version 2 and Version 3 of Rank2Types


Ignore:
Timestamp:
Nov 30, 2005 12:25:20 AM (10 years ago)
Author:
ross@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Rank2Types

    v2 v3  
    88Functions may have polymorphic arguments, described by explicit type signatures, e.g.
    99{{{
    10 runST :: (forall s. ST s a) -> a
     10g :: (forall a. a -> a) -> (Bool, Char)
     11g f = (f True, f 'a')
    1112}}}
    12 A special case of [wiki:RankNTypes].
     13In the definition of the function, polymorphic arguments must be matched, and can only be matched by a variable or wildcard (`_`) pattern.
     14
     15When such a function is used, it must be applied to an expression whose generalized type is at least as general as that declared, e.g.
     16{{{
     17g id
     18g undefined
     19}}}
     20The more general [wiki:RankNTypes] avoid these restrictions.
    1321
    1422== References ==
    1523
     24PolymorphicComponents are closely related.
     25
    1626== Pros ==
    17  * may be seen as syntactic sugar for PolymorphicComponents
    18 
    19    In my opinion rank 2 types are a prerequisite for [wiki:PolymorphicComponents], because in the
    20    presence of polymorphic components, the constructors of data types already have rank 2 types. -- Andres
    21  
    2227 * simple type inference
    23  * enables `runST` and similar devices
     28 * enables [http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad-ST.html runST] and similar devices
    2429 * used in cheap deforestation
    2530