6.1.1. Controlling editions and extensions — Glasgow Haskell Compiler 9.10.0.20240328 User's Guide

# 6.1.1. Controlling editions and extensions

GHC supports multiple language editions: `Haskell98`, `Haskell2010`, `GHC2021` and `GHC2024`. Each language edition consists of a collection of language extensions, and there are many other language extensions not currently part of a language edition but that can be enabled explicitly.

Currently, `GHC2021` is used by default if no other language edition is explicitly requested, for backwards compatibility purposes. Since later versions of GHC may use a different language edition by default, users are advised to declare a language edition explicitly. Using `GHC2024` is recommended for new code.

A language edition can be selected:

- at the package level, e.g. using `default-language: GHC2024` in a `.cabal` file;
- with a command-line flag prefixed by “`-X...`” (e.g. `-XGHC2024`); or
- for an individual module using the `LANGUAGE` pragma, e.g. `{-# LANGUAGE GHC2024 #-}`.

Selecting a language edition overrides any previous selection. It is not possible to disable a language edition.

Similarly, language extensions can be controlled (either enabled or disabled):

- at the package level, e.g. using `default-extensions: TemplateHaskell` in a `.cabal` file;
- with command-line flags, switched on by a command-line flag “`-X...`” (e.g. `-XTemplateHaskell`), and switched off by the flag “`-XNo...`”; (e.g. `-XNoTemplateHaskell`);
- for an individual module using the `LANGUAGE` pragma, e.g. `{-# LANGUAGE TemplateHaskell #-}` or `{-# LANGUAGE NoTemplateHaskell #-}`.

`GHC2024`

  Since: | 9.10.1

  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.

  Note that, because GHC2024 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 `GHC2024` language edition includes the following extensions:

  `BangPatterns` `BinaryLiterals` `ConstrainedClassMethods` `ConstraintKinds` `DataKinds` `DeriveDataTypeable` `DeriveFoldable` `DeriveFunctor` `DeriveGeneric` `DeriveLift` `DeriveTraversable` `DerivingStrategies` `DisambiguateRecordFields` `DoAndIfThenElse` `EmptyCase` `EmptyDataDecls` `EmptyDataDeriving` `ExistentialQuantification` `ExplicitForAll` `ExplicitNamespaces` `FieldSelectors` `FlexibleContexts` `FlexibleInstances` `ForeignFunctionInterface` `GADTs` `GADTSyntax` `GeneralisedNewtypeDeriving` | `HexFloatLiterals` `ImplicitPrelude` `ImportQualifiedPost` `InstanceSigs` `KindSignatures` `LambdaCase` `MonoLocalBinds` `MonomorphismRestriction` `MultiParamTypeClasses` `NamedFieldPuns` `NamedWildCards` `NumericUnderscores` `PatternGuards` `PolyKinds` `PostfixOperators` `RankNTypes` `RelaxedPolyRec` `RoleAnnotations` `ScopedTypeVariables` `StandaloneDeriving` `StandaloneKindSignatures` `StarIsType` `TraditionalRecordSyntax` `TupleSections` `TypeApplications` `TypeOperators` `TypeSynonymInstances`

`GHC2021`

  Since: | 9.2.1

  See `GHC2024` for general comments about `GHC20xx` language editions.

  Also note that due to a minor oversight, enabling this edition behaves slightly differently than enabling each of its constituent extensions. Specifically, while `TypeOperators` implies `ExplicitNamespaces`, `ExplicitNamespaces` is not included in `GHC2021`. Moreover, while `GADTs` is not part of `GHC2021`, the combination of `GADTSyntax` and `ExistentialQuantification` is enough to define and use GADTs.

  The `GHC2021` language edition includes the following extensions:

  `BangPatterns` `BinaryLiterals` `ConstrainedClassMethods` `ConstraintKinds` `DeriveDataTypeable` `DeriveFoldable` `DeriveFunctor` `DeriveGeneric` `DeriveLift` `DeriveTraversable` `DoAndIfThenElse` `EmptyCase` `EmptyDataDecls` `EmptyDataDeriving` `ExistentialQuantification` `ExplicitForAll` `FieldSelectors` `FlexibleContexts` `FlexibleInstances` `ForeignFunctionInterface` `GADTSyntax` `GeneralisedNewtypeDeriving` `HexFloatLiterals` `ImplicitPrelude` | `ImportQualifiedPost` `InstanceSigs` `KindSignatures` `MonomorphismRestriction` `MultiParamTypeClasses` `NamedFieldPuns` `NamedWildCards` `NumericUnderscores` `PatternGuards` `PolyKinds` `PostfixOperators` `RankNTypes` `RelaxedPolyRec` `ScopedTypeVariables` `StandaloneDeriving` `StandaloneKindSignatures` `StarIsType` `TraditionalRecordSyntax` `TupleSections` `TypeApplications` `TypeOperators` `TypeSynonymInstances` `NoExplicitNamespaces`

`Haskell2010`

  Compile using the Haskell 2010 language edition, as specified by the Haskell 2010 report. GHC aims to behave mostly as a Haskell 2010 compiler, but there are a few known deviations from the standard (see Haskell standards vs. Glasgow Haskell: language non-compliance).

  The `Haskell2010` language edition includes the following language extensions:

  `CUSKs` `DatatypeContexts` `DeepSubsumption` `DoAndIfThenElse` `EmptyDataDecls` `FieldSelectors` `ForeignFunctionInterface` | `ImplicitPrelude` `MonomorphismRestriction` `PatternGuards` `RelaxedPolyRec` `StarIsType` `TraditionalRecordSyntax`

`Haskell98`

  Compile using the Haskell 98 language edition, as specified by the Haskell 98 report. GHC aims to behave mostly as a Haskell 98 compiler, but there are a few known deviations from the standard (see Haskell standards vs. Glasgow Haskell: language non-compliance).

  The `Haskell98` language edition includes the following language extensions:

  `CUSKs` `DatatypeContexts` `DeepSubsumption` `FieldSelectors` `ImplicitPrelude` | `MonomorphismRestriction` `NPlusKPatterns` `NondecreasingIndentation` `StarIsType` `TraditionalRecordSyntax`

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:

  `ConstrainedClassMethods` `DeriveDataTypeable` `DeriveFoldable` `DeriveFunctor` `DeriveGeneric` `DeriveTraversable` `EmptyDataDecls` `ExistentialQuantification` `ExplicitNamespaces` `FlexibleContexts` `FlexibleInstances` `ForeignFunctionInterface` `FunctionalDependencies` `GeneralizedNewtypeDeriving` `ImplicitParams` `InterruptibleFFI` | `KindSignatures` `LiberalTypeSynonyms` `MagicHash` `MultiParamTypeClasses` `ParallelListComp` `PatternGuards` `PostfixOperators` `RankNTypes` `RecursiveDo` `ScopedTypeVariables` `StandaloneDeriving` `TypeOperators` `TypeSynonymInstances` `UnboxedTuples` `UnicodeSyntax` `UnliftedFFITypes`

  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.