| Version 4 (modified by ross@…, 7 years ago) |
|---|
Multi-parameter type classes
See ExtensionDescriptionHowto for information on how to write these extension descriptions. Please add any new extensions to the list of HaskellExtensions.
Brief Explanation
Classes take one or more arguments, becoming relations between types.
References
- Type classes: exploring the design space by Simon Peyton Jones, Mark Jones and Erik Meijer, Haskell Workshop 1997.
Pros
- offered by GHC and Hugs for years
- express more interesting relationships, as in the two occurrences in the base package of the Haskell hierarchical libraries:
class HasBounds a => IArray a e class (HasBounds a, Monad m) => MArray a e m
The instances supplied do not overlap.
Cons
- not very usable without FlexibleInstances or UndecidableInstances
- often lead to OverlappingInstances and ambiguity, though these can sometimes be avoided using FunctionalDependencies or AssociatedTypes. Examples include container and monad classes.
