Version 3 (modified by ross@…, 11 years ago) (diff) |
---|

# Rank 2 Types

See ExtensionDescriptionHowto for information on how to write these extension descriptions. Please add any new extensions to the list of HaskellExtensions.

## Brief Explanation

Functions may have polymorphic arguments, described by explicit type signatures, e.g.

g :: (forall a. a -> a) -> (Bool, Char) g f = (f True, f 'a')

In the definition of the function, polymorphic arguments must be matched, and can only be matched by a variable or wildcard (`_`) pattern.

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.

g id g undefined

The more general RankNTypes avoid these restrictions.

## References

PolymorphicComponents are closely related.

## Pros

- simple type inference
- enables runST and similar devices
- used in cheap deforestation

## Cons

- can be awkward in comparison with RankNTypes