This project relies on a number of GHC language extensions to support advanced type-level programming, generic deriving, Template Haskell, and ergonomic application code.
Each subsection links directly to the relevant part of the GHC User's Guide for that extension.
Note that anything newer than Haskell98 is technically considered a language-extension however many of these are very well supported and apart of the GHC2024 Extension Set
Allow type signatures that would otherwise be rejected as ambiguous, relying on use-sites (and type applications) to disambiguate.
Treat constraints as first-class types of kind
Constraint, allowing type synonyms and abstractions over constraint sets.
Promote data constructors to the type level, enabling type-level natural numbers, symbols, and more.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/data_kinds.html#extension-DataKinds
Generalise kinds so that type constructors can be polymorphic in their kind parameters, not just
Type.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/poly_kinds.html#extension-PolyKinds
Allow explicit kind annotations for type variables and type constructors.
Enable higher-rank polymorphism, e.g.
forall a. a -> f ain argument positions.
Make explicitly quantified type variables in a signature scope over the body of a definition.
Allow visible type application syntax (
funcFoo @Int) at use-sites.
Enable type families (type-level functions) associated with type classes or defined at the top level.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/type_families.html#extension-TypeFamilies
Allow symbolic names for types (e.g.
a :-> b), and treat them as infix operators.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/type_operators.html#extension-TypeOperators
Allow
forallinside constraints, e.g.forall a. c a => d a, expressing higher-rank relationships between instances.
Allow existentially-quantified type variables in data constructors, hiding type information behind a value.
Allow type classes with more than one parameter, e.g.
class HasDB env conn | env -> conn.
Attach functional dependencies (
| a -> b) to multi-parameter classes to guide instance resolution and improve type inference.
Relax restrictions on the shape of contexts in type signatures (e.g. allow nested type constructors in constraints).
Relax restrictions on the shape of instance heads, allowing instances for more complex type expressions.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/instances.html#extension-FlexibleInstances
Allow instance declarations that may not satisfy the usual termination/coverage conditions, needed for some advanced type-level patterns.
Allow explicit type signatures for individual methods inside instance declarations.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/instance_sigs.html#extension-InstanceSigs
Support default method implementations whose type is more general than the class method type, commonly used with
Generic.
Allow explicit role annotations (
type role T nominal representational) for type parameters, controlling representational equality and safe use ofcoerce.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/roles.html#extension-RoleAnnotations
Automatically derive
Generic/Generic1instances used for generic programming (e.g. JSON, DB schemas).
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/deriving_extra.html#extension-DeriveGeneric
Automatically derive
Data(and historicallyTypeable) instances for generic traversals and reflection-like libraries.
Allow
deriving Functorfor parameterised types with appropriate structure.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/deriving_extra.html#extension-DeriveFunctor
Allow
deriving Foldablefor traversable data structures.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/deriving_extra.html#extension-DeriveFoldable
Allow
deriving Traversable, which also implies appropriateFunctorandFoldablebehaviour.
Automatically derive
Liftinstances to embed values in Template Haskell splices.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/deriving_extra.html#extension-DeriveLift
Automatically derive instances for a
newtypebased on its underlying representation usingcoerce.
Allow
derivingclauses as separate top-level declarations, not just attached to the original data type.
Enable
deriving stock,deriving newtype,deriving anyclass, andderiving viastrategy keywords.
Generalised algebraic data types: link constructor result types and parameters in richer ways and enable more precise pattern matching.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/gadt.html#extension-GADTs
Allow data type declarations with no constructors.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/nullary_types.html#extension-EmptyDataDecls
Allow
caseexpressions (and\case) with zero alternatives, often used to express impossibility for empty types.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/empty_case.html#extension-EmptyCase
(Also listed above under type system.) Allow type constructors like
(a :*: b)using symbolic operators.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/type_operators.html#extension-TypeOperators
Enable
!patsyntax for strict pattern bindings and strictlet/wherebindings.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/strict.html#extension-BangPatterns
Allow
do,case,if,lambda,mdo, and\caseblocks to be passed as function arguments without extra parentheses or$.
Provide
\casesyntax for anonymous functions that immediately pattern match on their argument.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/lambda_case.html#extension-LambdaCase
Add
mdo/recnotation for monadic recursive bindings (used heavily in FRP-style code likereflex).
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/recursive_do.html#extension-RecursiveDo
Enable tuple sections such as
(, x)or(a, , c)as partially-applied tuple constructors.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/tuple_sections.html#extension-TupleSections
Run the C preprocessor (
cpp) over Haskell source files, enabling#if,#ifdef, etc. for conditional compilation.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/cpp.html#extension-CPP
Disable the Haskell 2010 monomorphism restriction so bindings without signatures remain polymorphic in more cases.
(Use the NoMonomorphismRestriction flag form of this extension.)
Make string literals polymorphic via the
IsStringtypeclass (so"foo"can beText,ByteString, etc.).
Enable Template Haskell quotations and splices (
[| .. |],$(..)) for compile-time metaprogramming and code generation.
Enable quasiquotation syntax (
[quoter| ... |]) to embed and parse domain-specific languages such as HTML or Markdown.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/quasi_quotes.html#extension-QuasiQuotes
(Also listed above under classes/instances.) Allow explicit role annotations for type parameters.
Docs: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/roles.html#extension-RoleAnnotations
(Also listed above under deriving.) Derive newtype instances based on representation equality.