Difference between revisions of "Language extensions"

From HaskellWiki
Jump to navigation Jump to search
(5 intermediate revisions by the same user not shown)
Line 12: Line 12:
 
* [[Datatype contexts|DatatypeContexts]] : Add type constraints to your datatype.
 
* [[Datatype contexts|DatatypeContexts]] : Add type constraints to your datatype.
 
* [[Default signatures|DefaultSignatures]]
 
* [[Default signatures|DefaultSignatures]]
  +
* Derive:
* [[Generics|DeriveGeneric]]
 
  +
** [http://www.haskell.org/ghc/docs/latest/html/users_guide/deriving.html#deriving-typeable DeriveDataTypeable]
  +
** [http://www.haskell.org/ghc/docs/latest/html/users_guide/deriving.html#deriving-typeable DeriveGeneric]
  +
** [http://www.haskell.org/ghc/docs/latest/html/users_guide/deriving.html#deriving-typeable DeriveFunctor]
  +
** [http://www.haskell.org/ghc/docs/latest/html/users_guide/deriving.html#deriving-typeable DeriveFoldable]
  +
** [http://www.haskell.org/ghc/docs/latest/html/users_guide/deriving.html#deriving-typeable DeriveTraversable]
  +
** [http://www.haskell.org/ghc/docs/latest/html/users_guide/deriving.html#id616911 GeneralizedNewtypeDeriving]
 
* [[Existential type|ExistentialQuantification]]
 
* [[Existential type|ExistentialQuantification]]
 
* [[Flexible contexts|FlexibleContexts]]
 
* [[Flexible contexts|FlexibleContexts]]
Line 19: Line 25:
 
* [[GADT]]s : Generalised algebraic datatypes - A more general approach to algebraic datatypes.
 
* [[GADT]]s : Generalised algebraic datatypes - A more general approach to algebraic datatypes.
 
* [[Implicit parameters|ImplicitParams]]
 
* [[Implicit parameters|ImplicitParams]]
  +
* [[KindSignatures]]
 
* [[Multi-parameter type class|MultiParamTypeClasses]] : Enable multiple type parameters in type classes.
 
* [[Multi-parameter type class|MultiParamTypeClasses]] : Enable multiple type parameters in type classes.
  +
* [[Monomorphism restriction|NoMonomorphismRestriction]]
 
* [[Overlapping instance|OverlappingInstances]]
 
* [[Overlapping instance|OverlappingInstances]]
 
* [[Rank-N types|Rank2Types]]
 
* [[Rank-N types|Rank2Types]]
Line 25: Line 33:
 
* [[Scoped type variables|ScopedTypeVariables]]
 
* [[Scoped type variables|ScopedTypeVariables]]
 
* [[Template Haskell|TemplateHaskell]]
 
* [[Template Haskell|TemplateHaskell]]
  +
* [http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#tuple-sections TupleSections] : Allow tuples to be partially applied.
 
* [[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]
   
   

Revision as of 18:18, 18 December 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.