haskell / 9 / users_guide / exts / control.html

6.1.1. Controlling extensions

Language extensions can be controlled (i.e. allowed or not) in two ways:

  • Every language extension can be switched on by a command-line flag “-X...” (e.g. -XTemplateHaskell), and switched off by the flag “-XNo...”; (e.g. -XNoTemplateHaskell).
  • Language extensions can also be enabled using the LANGUAGE pragma, thus {-# LANGUAGE TemplateHaskell #-} (see LANGUAGE pragma).
GHC2021

GHC blesses a number of extensions, beyond Haskell 2010, to be suitable to turned on by default. These extensions are considered to be stable and conservative.

GHC2021 is used by GHC if neither Haskell98 nor Haskell2010 is turned on explicitly. Since later versions of GHC may use a later GHC20xx by default, users are advised to declare the language set explicitly with -XGHC2021.

Note that, because GHC2021 includes a number of non-standardized extensions, the stability guarantees it provides are not quite as strong as those provided by, e.g., Haskell2010. While GHC does take pains to avoid changing the semantics of these extensions, changes may still happen (e.g. the simplified subsumption change introduced in GHC 9.0 which caused GHC to reject some programs using RankNTypes).

The GHC2021 language set comprises the following extensions:

Haskell2010

Compile Haskell 2010 language variant. Enables the following language extensions:

Haskell98

Compile using Haskell 98 language variant. Enables the following language extensions:

Although not recommended, the deprecated -fglasgow-exts flag enables a large swath of the extensions supported by GHC at once.

-fglasgow-exts

The flag -fglasgow-exts is equivalent to enabling the following extensions:

Enabling these options is the only effect of -fglasgow-exts. We are trying to move away from this portmanteau flag, and towards enabling features individually.

© 2002–2007 The University Court of the University of Glasgow. All rights reserved.
Licensed under the Glasgow Haskell Compiler License.
https://downloads.haskell.org/~ghc/9.4.2/docs/users_guide/exts/control.html