HORIZON HASKELLDocslts/ghc-10.0.x2b276322026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 2b27632 · 2026-10-31

Moduleghc-10.0.0.20260917GHC2024

Language.Haskell.Syntax.Decls

Abstract syntax of global declarations.

Definitions for: SynDecl and ConDecl, ClassDecl, InstDecl, DefaultDecl.

Contents
  1. Toplevel declarations
  2. Class or type declarations
  3. Instance declarations
  4. Standalone deriving declarations
  5. Deriving strategies
  6. RULE declarations
  7. default declarations
  8. Template haskell declaration splice
  9. Foreign function interface declarations
  10. Data-constructor declarations
  11. Document comments
  12. Deprecations
  13. Annotations
  14. Role annotations
  15. Injective type families
  16. Grouping
  17. Warnings
  18. Extension
Synopsis

Toplevel declarations

datadata HsDecl p

A Haskell Declaration

Constructors

Instances7Data, Outputable, HasHaddock, Anno, …
datadata HsDataDefn pass

Haskell Data type Definition

Constructors

Instances8Data, HasLoc, Outputable, ToHie, HasHaddock, …
datadata FunDep pass
#

Constructors

Instances6Data, Outputable, ToHie, Anno
datadata HsDerivingClause pass

A single deriving clause of a data declaration.

Constructors

Instances9Data, Outputable, ToHie, HasHaddock, Anno, …
datadata DerivClauseTys pass

The types mentioned in a single deriving clause. This can come in two forms, DctSingle or DctMulti, depending on whether the types are surrounded by enclosing parentheses or not. These parentheses are semantically different than HsParTy. For example, deriving () means "derive zero classes" rather than "derive an instance of the 0-tuple".

DerivClauseTys use LHsSigType because deriving clauses can mention type variables that aren't bound by the datatype, e.g.

data T b = ... deriving (C [a])

should produce a derived instance for C [a] (T b).

Constructors

Instances7Data, Outputable, ToHie, HasHaddock, Anno, …
datadata DataDefnCons a

Whether a data-type declaration is data or newtype, and its constructors.

Constructors

Instances7Functor, Foldable, Traversable, Eq, Data, HasLoc, …
datadata StandaloneKindSig pass
#
Instances7Data, Outputable, ToHie, Anno, …

Class or type declarations

datadata TyClDecl pass

A type or class declaration.

Constructors

Instances6Data, Outputable, ToHie, Anno
datadata TyClGroup pass
Instances5Data, Outputable, ToHie
datadata FamilyDecl pass
Instances6Data, Outputable, ToHie, Anno

Instance declarations

datadata InstDecl pass
Instances6Data, Outputable, ToHie, Anno
datadata FamilyInfo pass
#

Constructors

Instances5Data, Outputable, ToHie
datadata TyFamInstDecl pass

Type Family Instance Declaration

Instances6Data, Outputable, ToHie, Anno
newtypenewtype DataFamInstDecl pass

Data Family Instance Declaration

Constructors

Instances6Data, Outputable, ToHie, Anno
datadata FamEqn pass rhs

Family Equation

One equation in a type family instance declaration, data family instance declaration, or type family default. See Note [Type family instance declarations in HsSyn] See Note [Family instance declaration binders]

Constructors

Instances9Data, HasLoc, ToHie, Anno, …
typetype HsFamEqnPats pass = [LHsTypeArg pass]

HsFamEqnPats represents patterns on the left-hand side of a type instance, e.g. `type instance F k (a :: k) = a` has patterns `k` and `(a :: k)`.

HsFamEqnPats used to be called HsTyPats but it was renamed to avoid confusion with a different notion of type patterns, see #23657.

datadata ClsInstDecl pass
Instances6Data, Outputable, ToHie, Anno

Standalone deriving declarations

datadata DerivDecl pass

Stand-alone 'deriving instance' declaration

Constructors

Instances6Data, Outputable, ToHie, Anno

Deriving strategies

datadata DerivStrategy pass

Which technique the user explicitly requested when deriving an instance.

Constructors

Instances6Data, Outputable, ToHie, Anno

RULE declarations

datadata RuleDecls pass

Rule Declarations

Instances6Data, Outputable, ToHie, Anno
datadata RuleDecl pass

Rule Declaration

Constructors

Instances6Data, Outputable, ToHie, Anno
datadata RuleBndr pass

Rule Binder

Constructors

Instances6Data, Outputable, ToHie, Anno

default declarations

datadata DefaultDecl pass

Default Declaration

Instances6Data, Outputable, ToHie, Anno

Template haskell declaration splice

A splice can appear with various decorations wrapped around it. This data type captures explicitly how it was originally written, for use in the pretty printer.

Constructors

Instances4Eq, Data, Show, Outputable
datadata SpliceDecl p
Instances6Data, Outputable, ToHie, Anno

Foreign function interface declarations

datadata ForeignDecl pass
Instances6Data, Outputable, ToHie, Anno
datadata ForeignImport pass

Specification Of an imported external entity in dependence on the calling convention

Constructors

  • CImport (XCImport pass) (XRec pass CCallConv) (XRec pass Safety) (Maybe (Header pass)) (CImportSpec pass)

    Import of a C entity

    • the two strings specifying a header file or library may be empty, which indicates the absence of a header or object specification (both are not used in the case of CWrapper and when CFunction has a dynamic target)

    • the calling convention is irrelevant for code generation in the case of CLabel, but is needed for pretty printing

    • Safety is irrelevant for CLabel and CWrapper

  • XForeignImport !(XXForeignImport pass)
Instances5Data, Outputable, ToHie
datadata ForeignExport pass

Specification of an externally exported entity in dependence on the calling convention

Constructors

Instances5Data, Outputable, ToHie
datadata CCallConv
#
Instances8Enum, Eq, Data, Show, NFData, Outputable, …
  • Enum CCallConvDefined in ghc-10.0.0.20260917 · Language.Haskell.Syntax.Decls.Foreign
  • Eq CCallConvDefined in ghc-10.0.0.20260917 · Language.Haskell.Syntax.Decls.Foreign
  • Data CCallConvDefined in ghc-10.0.0.20260917 · Language.Haskell.Syntax.Decls.Foreign
  • Show CCallConvDefined in ghc-10.0.0.20260917 · Language.Haskell.Syntax.Decls.Foreign
  • NFData CCallConvDefined in ghc-10.0.0.20260917 · Language.Haskell.Syntax.Decls.Foreign
  • Outputable CCallConvDefined in ghc-10.0.0.20260917 · GHC.Types.ForeignCall · orphan
  • Binary CCallConvDefined in ghc-10.0.0.20260917 · GHC.Types.ForeignCall · orphan
  • type Anno CCallConv = EpaLocationDefined in ghc-10.0.0.20260917 · GHC.Hs.Decls · orphan
datadata CCallTarget pass

How to call a particular function in C-land.

Constructors

Instances6Eq, Data, NFData, Binary

Data-constructor declarations

datadata ConDecl pass
data T b = forall a. Eq a => MkT a b
  MkT :: forall b a. Eq a => MkT a b

data T b where
     MkT1 :: Int -> T Int

data T = Int MkT Int
       | MkT2

data T a where
     Int MkT Int :: T Int

data Constructor Declaration

Constructors

Instances7Data, Outputable, ToHie, HasHaddock, Anno, …
datadata HsConDeclGADTDetails pass

The arguments in a GADT constructor. Unlike Haskell98-style constructors, GADT constructors cannot be declared with infix syntax. As a result, we do not use HsConDetails here, as InfixCon would be an unrepresentable state. (There is a notion of infix GADT constructors for the purposes of derived Show instances—see Note [Infix GADT constructors] in GHC.Tc.TyCl—but that is an orthogonal concern.)

Instances4Data, ToHie

Document comments

datadata DocDecl pass

Documentation comment Declaration

Instances4Data, Outputable, ToHie, Anno

Deprecations

datadata WarnDecl pass

Warning pragma Declaration

Constructors

Instances6Data, Outputable, ToHie, Anno
datadata WarnDecls pass

Warning pragma Declarations

Instances6Data, Outputable, ToHie, Anno

Annotations

datadata AnnDecl pass

Annotation Declaration

Constructors

Instances6Data, Outputable, ToHie, Anno
datadata AnnProvenance pass

Annotation Provenance

Instances4Data, ToHie

Role annotations

datadata RoleAnnotDecl pass

Role Annotation Declaration

Instances6Data, Outputable, ToHie, Anno

Injective type families

datadata FamilyResultSig pass

type Family Result Signature

Constructors

Instances5Data, ToHie, Anno
datadata InjectivityAnn pass

If the user supplied an injectivity annotation it is represented using InjectivityAnn. At the moment this is a single injectivity condition - see Note [Injectivity annotation]. `Located name` stores the LHS of injectivity condition. `[Located name]` stores the RHS of injectivity condition. Example:

type family Foo a b c = r | r -> a c where ...

This will be represented as "InjectivityAnn r [a, c]"

Instances5Data, ToHie, Anno

Grouping

datadata HsGroup p

Haskell Group

A HsDecl is categorised into a HsGroup before being fed to the renamer.

Instances4Data, Outputable

Warnings

datadata WarningTxt pass

Warning Text

reason/explanation from a WARNING or DEPRECATED pragma

Instances10Eq, Data, Generic, Outputable, Rep, Anno, …
newtypenewtype WarningCategory
#
Instances8Eq, Data, Show, NFData, Outputable, Uniquable, …
datadata InWarningCategory pass
#
Instances8Eq, Data, Outputable, Anno, …

Extension