|Version 3 (modified by ross@…, 10 years ago) (diff)|
Haskell 98 provides only rank-1 types: universal quantification is over the whole type expressions, and is implicit, e.g.
const :: a -> b -> a
Rank-2 types may have polymorphic arguments, marked by forall, e.g.
plus :: (forall a. a -> a) -> (forall a. a -> a) -> b -> b
Rank-3 types may have arguments of rank-2 type, e.g.
f3 :: ((forall a. a->a) -> Int) -> Bool -> Bool
and so on to arbitrary depth.
foralls in the second argument of -> could be permitted as a convenience, but they are equivalent to foralls further out. foralls are not permitted inside arguments of other type constructors.
The GHC User's Guide has some vague remarks about how type signature information is used. Perhaps someone could elaborate.
- Arbitrary-rank polymorphism in the GHC User's Guide.
- Practical type inference for arbitrary-rank types, Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich and Mark Shields, July 2005.
- Rank2Types are a special case
- More convenient than encodings using PolymorphicComponents
- More complex than Rank2Types, which cover the most common cases (and can encode the rest, though clumsily).
- No clear programmer-level description of the restrictions that apply.