Changes between Version 3 and Version 4 of Rank2Types


Ignore:
Timestamp:
Dec 2, 2005 4:30:29 PM (8 years ago)
Author:
ross@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Rank2Types

    v3 v4  
    66== Brief Explanation == 
    77 
    8 Functions may have polymorphic arguments, described by explicit type signatures, e.g. 
    9 {{{ 
     8Functions may have polymorphic arguments, subject to three restrictions: 
     9 
     10 * Such functions must have explicit type signatures, using `forall` to bind polymorphic type variables, e.g. 
     11   {{{ 
    1012g :: (forall a. a -> a) -> (Bool, Char) 
     13}}} 
     14 
     15 * In the definition of the function, polymorphic arguments must be matched on the left-hand side, and can only be matched by a variable or wildcard (`_`) pattern.  The variable then has the polymorphic type of the corresponding argument, e.g. 
     16   {{{ 
    1117g f = (f True, f 'a') 
    1218}}} 
    13 In the definition of the function, polymorphic arguments must be matched, and can only be matched by a variable or wildcard (`_`) pattern. 
    1419 
    15 When 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 {{{ 
     20 * When such a function is used, it must be applied to at least as many arguments to include the polymorphic ones (so it's a good idea to put those first).  Each expression must have a generalized type at least as general as that declared for the corresponding argument, e.g. 
     21   {{{ 
    1722g id 
    1823g undefined 
    1924}}} 
    20 The more general [wiki:RankNTypes] avoid these restrictions. 
     25The more general [wiki:RankNTypes] remove the last two restrictions. 
    2126 
    2227== References == 
    2328 
    24 PolymorphicComponents are closely related. 
     29PolymorphicComponents do the same thing for data constructors. 
    2530 
    2631== Pros == 
    2732 * simple type inference 
     33 * offered by GHC and Hugs for more than 15 years 
    2834 * enables [http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad-ST.html runST] and similar devices 
    2935 * used in cheap deforestation