Language extensions
From HaskellWiki
(Difference between revisions)
(→List of language extensions by name) |
|||
| Line 29: | Line 29: | ||
* [[GHC/Type families|TypeFamilies]] | * [[GHC/Type families|TypeFamilies]] | ||
* [[Undecidable instance|UndecidableInstances]] | * [[Undecidable instance|UndecidableInstances]] | ||
| + | * [http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#view-patterns ViewPatterns] | ||
[[Category:Language extensions]] | [[Category:Language extensions]] | ||
Revision as of 18:30, 1 November 2012
Language extensions are used to enable language features in Haskell that may seem useful in certain cases. They can be used to loosen restrictions in the type system or add completely new language constructs to Haskell.
They can be enabled using the LANGUAGE pragma or (in GHC) using the flag -X. The LANGUAGE pragma should be preferred here.
Before just using the language extension that fits your need, think about when it is useful and what risk it may bring to your program.
List of language extensions by name
This list is far from complete and needs extension.
- DatatypeContexts : Add type constraints to your datatype.
- DefaultSignatures
- DeriveGeneric
- ExistentialQuantification
- FlexibleContexts
- FlexibleInstances : Allow a type parameter to occure twice within a type class instance.
- FunctionalDependencies : Are used to constrain the parameters of type classes.
- GADTs : Generalised algebraic datatypes - A more general approach to algebraic datatypes.
- ImplicitParams
- KindSignatures
- MultiParamTypeClasses : Enable multiple type parameters in type classes.
- NoMonomorphismRestriction
- OverlappingInstances
- Rank2Types
- RankNTypes
- ScopedTypeVariables
- TemplateHaskell
- TypeFamilies
- UndecidableInstances
- ViewPatterns
