Difference between revisions of "Language extensions"

From HaskellWiki
Jump to navigation Jump to search
(fix two doc links)
(don't link to gitlab version of docs (it is a development version))
Line 7: Line 7:
 
</hask>
 
</hask>
   
or (in GHC) using [https://ghc.gitlab.haskell.org/ghc/doc/users_guide/lang.html flags] <code>-X<Extension></code>.
+
or (in GHC) using [https://downloads.haskell.org/ghc/latest/docs/html/users_guide/lang.html flags] <code>-X<Extension></code>.
   
 
Before just using the language extension that fits your need, [[Use of language extensions|think about
 
Before just using the language extension that fits your need, [[Use of language extensions|think about
Line 25: Line 25:
 
** [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#deriving-typeable DeriveTraversable]
 
** [http://www.haskell.org/ghc/docs/latest/html/users_guide/deriving.html#id616911 GeneralizedNewtypeDeriving]
 
** [http://www.haskell.org/ghc/docs/latest/html/users_guide/deriving.html#id616911 GeneralizedNewtypeDeriving]
* [https://ghc.gitlab.haskell.org/ghc/doc/users_guide/glasgow_exts.html#duplicate-record-fields DuplicateRecordFields] (GHC 8.0.1+) : Allow definition of record types with identically-named fields.
+
* [https://downloads.haskell.org/ghc/latest/docs/html/users_guide/glasgow_exts.html#duplicate-record-fields DuplicateRecordFields] (GHC 8.0.1+) : Allow definition of record types with identically-named fields.
 
* [[Existential type|ExistentialQuantification]]
 
* [[Existential type|ExistentialQuantification]]
 
* [[Flexible contexts|FlexibleContexts]]
 
* [[Flexible contexts|FlexibleContexts]]

Revision as of 19:42, 4 April 2019

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

{-# LANGUAGE <Extension>, <Extension> #-}

or (in GHC) using flags -X<Extension>.

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.

See also