Changes between Version 3 and Version 4 of Rank2Types
 Timestamp:
 Dec 2, 2005 4:30:29 PM (11 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

Rank2Types
v3 v4 6 6 == Brief Explanation == 7 7 8 Functions may have polymorphic arguments, described by explicit type signatures, e.g. 9 {{{ 8 Functions 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 {{{ 10 12 g :: (forall a. a > a) > (Bool, Char) 13 }}} 14 15 * In the definition of the function, polymorphic arguments must be matched on the lefthand 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 {{{ 11 17 g f = (f True, f 'a') 12 18 }}} 13 In the definition of the function, polymorphic arguments must be matched, and can only be matched by a variable or wildcard (`_`) pattern.14 19 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 {{{ 17 22 g id 18 23 g undefined 19 24 }}} 20 The more general [wiki:RankNTypes] avoid theserestrictions.25 The more general [wiki:RankNTypes] remove the last two restrictions. 21 26 22 27 == References == 23 28 24 PolymorphicComponents are closely related.29 PolymorphicComponents do the same thing for data constructors. 25 30 26 31 == Pros == 27 32 * simple type inference 33 * offered by GHC and Hugs for more than 15 years 28 34 * enables [http://www.haskell.org/ghc/docs/latest/html/libraries/base/ControlMonadST.html runST] and similar devices 29 35 * used in cheap deforestation