ghc-7.10.3: The GHC API

Safe Haskell | None
Language | Haskell2010

HsDecls

Contents

- Toplevel declarations
  - Class or type declarations
  - Instance declarations
  - Standalone deriving declarations
  - `RULE` declarations
  - `VECTORISE` declarations
  - `default` declarations
  - Template haskell declaration splice
  - Foreign function interface declarations
  - Data-constructor declarations
  - Document comments
  - Deprecations
  - Annotations
  - Role annotations
- Grouping

Description

Abstract syntax of global declarations.

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

Synopsis

- data HsDecl id
  - = TyClD (TyClDecl id)
  - | InstD (InstDecl id)
  - | DerivD (DerivDecl id)
  - | ValD (HsBind id)
  - | SigD (Sig id)
  - | DefD (DefaultDecl id)
  - | ForD (ForeignDecl id)
  - | WarningD (WarnDecls id)
  - | AnnD (AnnDecl id)
  - | RuleD (RuleDecls id)
  - | VectD (VectDecl id)
  - | SpliceD (SpliceDecl id)
  - | DocD DocDecl
  - | QuasiQuoteD (HsQuasiQuote id)
  - | RoleAnnotD (RoleAnnotDecl id)
- type LHsDecl id = Located (HsDecl id)
- data HsDataDefn name = HsDataDefn {
  - dd_ND :: NewOrData
  - dd_ctxt :: LHsContext name
  - dd_cType :: Maybe (Located CType)
  - dd_kindSig :: Maybe (LHsKind name)
  - dd_cons :: [LConDecl name]
  - dd_derivs :: Maybe (Located [LHsType name])
  }
- data TyClDecl name
  - = FamDecl {
    - tcdFam :: FamilyDecl name
    }
  - | SynDecl {
    - tcdLName :: Located name
    - tcdTyVars :: LHsTyVarBndrs name
    - tcdRhs :: LHsType name
    - tcdFVs :: PostRn name NameSet
    }
  - | DataDecl {
    - tcdLName :: Located name
    - tcdTyVars :: LHsTyVarBndrs name
    - tcdDataDefn :: HsDataDefn name
    - tcdFVs :: PostRn name NameSet
    }
  - | ClassDecl {
    - tcdCtxt :: LHsContext name
    - tcdLName :: Located name
    - tcdTyVars :: LHsTyVarBndrs name
    - tcdFDs :: [Located (FunDep (Located name))]
    - tcdSigs :: [LSig name]
    - tcdMeths :: LHsBinds name
    - tcdATs :: [LFamilyDecl name]
    - tcdATDefs :: [LTyFamDefltEqn name]
    - tcdDocs :: [LDocDecl]
    - tcdFVs :: PostRn name NameSet
    }
- type LTyClDecl name = Located (TyClDecl name)
- data TyClGroup name = TyClGroup {
  - group_tyclds :: [LTyClDecl name]
  - group_roles :: [LRoleAnnotDecl name]
  }
- tyClGroupConcat :: [TyClGroup name] -> [LTyClDecl name]
- mkTyClGroup :: [LTyClDecl name] -> TyClGroup name
- isClassDecl :: TyClDecl name -> Bool
- isDataDecl :: TyClDecl name -> Bool
- isSynDecl :: TyClDecl name -> Bool
- tcdName :: TyClDecl name -> name
- isFamilyDecl :: TyClDecl name -> Bool
- isTypeFamilyDecl :: TyClDecl name -> Bool
- isDataFamilyDecl :: TyClDecl name -> Bool
- isOpenTypeFamilyInfo :: FamilyInfo name -> Bool
- isClosedTypeFamilyInfo :: FamilyInfo name -> Bool
- tyFamInstDeclName :: OutputableBndr name => TyFamInstDecl name -> name
- tyFamInstDeclLName :: OutputableBndr name => TyFamInstDecl name -> Located name
- countTyClDecls :: [TyClDecl name] -> (Int, Int, Int, Int, Int)
- pprTyClDeclFlavour :: TyClDecl a -> SDoc
- tyClDeclLName :: TyClDecl name -> Located name
- tyClDeclTyVars :: OutputableBndr name => TyClDecl name -> LHsTyVarBndrs name
- hsDeclHasCusk :: TyClDecl name -> Bool
- famDeclHasCusk :: FamilyDecl name -> Bool
- data FamilyDecl name = FamilyDecl {
  - fdInfo :: FamilyInfo name
  - fdLName :: Located name
  - fdTyVars :: LHsTyVarBndrs name
  - fdKindSig :: Maybe (LHsKind name)
  }
- type LFamilyDecl name = Located (FamilyDecl name)
- data InstDecl name
  - = ClsInstD {
    - cid_inst :: ClsInstDecl name
    }
  - | DataFamInstD {
    - dfid_inst :: DataFamInstDecl name
    }
  - | TyFamInstD {
    - tfid_inst :: TyFamInstDecl name
    }
- type LInstDecl name = Located (InstDecl name)
- data NewOrData
  - = NewType
  - | DataType
- data FamilyInfo name
  - = DataFamily
  - | OpenTypeFamily
  - | ClosedTypeFamily [LTyFamInstEqn name]
- data TyFamInstDecl name = TyFamInstDecl {
  - tfid_eqn :: LTyFamInstEqn name
  - tfid_fvs :: PostRn name NameSet
  }
- type LTyFamInstDecl name = Located (TyFamInstDecl name)
- instDeclDataFamInsts :: [LInstDecl name] -> [DataFamInstDecl name]
- data DataFamInstDecl name = DataFamInstDecl {
  - dfid_tycon :: Located name
  - dfid_pats :: HsTyPats name
  - dfid_defn :: HsDataDefn name
  - dfid_fvs :: PostRn name NameSet
  }
- type LDataFamInstDecl name = Located (DataFamInstDecl name)
- pprDataFamInstFlavour :: DataFamInstDecl name -> SDoc
- data TyFamEqn name pats = TyFamEqn {
  - tfe_tycon :: Located name
  - tfe_pats :: pats
  - tfe_rhs :: LHsType name
  }
- type TyFamInstEqn name = TyFamEqn name (HsTyPats name)
- type LTyFamInstEqn name = Located (TyFamInstEqn name)
- type TyFamDefltEqn name = TyFamEqn name (LHsTyVarBndrs name)
- type LTyFamDefltEqn name = Located (TyFamDefltEqn name)
- type HsTyPats name = HsWithBndrs name [LHsType name]
- type LClsInstDecl name = Located (ClsInstDecl name)
- data ClsInstDecl name = ClsInstDecl {
  - cid_poly_ty :: LHsType name
  - cid_binds :: LHsBinds name
  - cid_sigs :: [LSig name]
  - cid_tyfam_insts :: [LTyFamInstDecl name]
  - cid_datafam_insts :: [LDataFamInstDecl name]
  - cid_overlap_mode :: Maybe (Located OverlapMode)
  }
- data DerivDecl name = DerivDecl {
  - deriv_type :: LHsType name
  - deriv_overlap_mode :: Maybe (Located OverlapMode)
  }
- type LDerivDecl name = Located (DerivDecl name)
- type LRuleDecls name = Located (RuleDecls name)
- data RuleDecls name = HsRules {
  - rds_src :: SourceText
  - rds_rules :: [LRuleDecl name]
  }
- data RuleDecl name = HsRule (Located RuleName) Activation [LRuleBndr name] (Located (HsExpr name)) (PostRn name NameSet) (Located (HsExpr name)) (PostRn name NameSet)
- type LRuleDecl name = Located (RuleDecl name)
- data RuleBndr name
  - = RuleBndr (Located name)
  - | RuleBndrSig (Located name) (HsWithBndrs name (LHsType name))
- type LRuleBndr name = Located (RuleBndr name)
- collectRuleBndrSigTys :: [RuleBndr name] -> [HsWithBndrs name (LHsType name)]
- flattenRuleDecls :: [LRuleDecls name] -> [LRuleDecl name]
- data VectDecl name
  - = HsVect SourceText (Located name) (LHsExpr name)
  - | HsNoVect SourceText (Located name)
  - | HsVectTypeIn SourceText Bool (Located name) (Maybe (Located name))
  - | HsVectTypeOut Bool TyCon (Maybe TyCon)
  - | HsVectClassIn SourceText (Located name)
  - | HsVectClassOut Class
  - | HsVectInstIn (LHsType name)
  - | HsVectInstOut ClsInst
- type LVectDecl name = Located (VectDecl name)
- lvectDeclName :: NamedThing name => LVectDecl name -> Name
- lvectInstDecl :: LVectDecl name -> Bool
- data DefaultDecl name = DefaultDecl [LHsType name]
- type LDefaultDecl name = Located (DefaultDecl name)
- data SpliceExplicitFlag
  - = ExplicitSplice
  - | ImplicitSplice
- data SpliceDecl id = SpliceDecl (Located (HsSplice id)) SpliceExplicitFlag
- type LSpliceDecl name = Located (SpliceDecl name)
- data ForeignDecl name
  - = ForeignImport (Located name) (LHsType name) (PostTc name Coercion) ForeignImport
  - | ForeignExport (Located name) (LHsType name) (PostTc name Coercion) ForeignExport
- type LForeignDecl name = Located (ForeignDecl name)
- data ForeignImport = CImport (Located CCallConv) (Located Safety) (Maybe Header) CImportSpec (Located SourceText)
- data ForeignExport = CExport (Located CExportSpec) (Located SourceText)
- noForeignImportCoercionYet :: PlaceHolder
- noForeignExportCoercionYet :: PlaceHolder
- data CImportSpec
  - = CLabel CLabelString
  - | CFunction CCallTarget
  - | CWrapper
- data ConDecl name = ConDecl {
  - con_names :: [Located name]
  - con_explicit :: HsExplicitFlag
  - con_qvars :: LHsTyVarBndrs name
  - con_cxt :: LHsContext name
  - con_details :: HsConDeclDetails name
  - con_res :: ResType (LHsType name)
  - con_doc :: Maybe LHsDocString
  - con_old_rec :: Bool
  }
- type LConDecl name = Located (ConDecl name)
- data ResType ty
  - = ResTyH98
  - | ResTyGADT SrcSpan ty
- type HsConDeclDetails name = HsConDetails (LBangType name) (Located [LConDeclField name])
- hsConDeclArgTys :: HsConDeclDetails name -> [LBangType name]
- data DocDecl
  - = DocCommentNext HsDocString
  - | DocCommentPrev HsDocString
  - | DocCommentNamed String HsDocString
  - | DocGroup Int HsDocString
- type LDocDecl = Located DocDecl
- docDeclDoc :: DocDecl -> HsDocString
- data WarnDecl name = Warning [Located name] WarningTxt
- type LWarnDecl name = Located (WarnDecl name)
- data WarnDecls name = Warnings {
  - wd_src :: SourceText
  - wd_warnings :: [LWarnDecl name]
  }
- type LWarnDecls name = Located (WarnDecls name)
- data AnnDecl name = HsAnnotation SourceText (AnnProvenance name) (Located (HsExpr name))
- type LAnnDecl name = Located (AnnDecl name)
- data AnnProvenance name
  - = ValueAnnProvenance (Located name)
  - | TypeAnnProvenance (Located name)
  - | ModuleAnnProvenance
- annProvenanceName_maybe :: AnnProvenance name -> Maybe name
- data RoleAnnotDecl name = RoleAnnotDecl (Located name) [Located (Maybe Role)]
- type LRoleAnnotDecl name = Located (RoleAnnotDecl name)
- roleAnnotDeclName :: RoleAnnotDecl name -> name
- data HsGroup id = HsGroup {
  - hs_valds :: HsValBinds id
  - hs_splcds :: [LSpliceDecl id]
  - hs_tyclds :: [TyClGroup id]
  - hs_instds :: [LInstDecl id]
  - hs_derivds :: [LDerivDecl id]
  - hs_fixds :: [LFixitySig id]
  - hs_defds :: [LDefaultDecl id]
  - hs_fords :: [LForeignDecl id]
  - hs_warnds :: [LWarnDecls id]
  - hs_annds :: [LAnnDecl id]
  - hs_ruleds :: [LRuleDecls id]
  - hs_vects :: [LVectDecl id]
  - hs_docs :: [LDocDecl]
  }
- emptyRdrGroup :: HsGroup a
- emptyRnGroup :: HsGroup a
- appendGroups :: HsGroup a -> HsGroup a -> HsGroup a

# Toplevel declarations

data HsDecl id

A Haskell Declaration

Constructors

TyClD (TyClDecl id) | A type or class declaration.
InstD (InstDecl id) | An instance declaration.
DerivD (DerivDecl id) |
ValD (HsBind id) |
SigD (Sig id) |
DefD (DefaultDecl id) |
ForD (ForeignDecl id) |
WarningD (WarnDecls id) |
AnnD (AnnDecl id) |
RuleD (RuleDecls id) |
VectD (VectDecl id) |
SpliceD (SpliceDecl id) |
DocD DocDecl |
QuasiQuoteD (HsQuasiQuote id) |
RoleAnnotD (RoleAnnotDecl id) |

Instances

DataId id => Data (HsDecl id) |
OutputableBndr name => Outputable (HsDecl name) |

type LHsDecl id

Arguments

= Located (HsDecl id)

When in a list this may have

- `AnnKeywordId` : `AnnSemi`

data HsDataDefn name

Constructors

HsDataDefn | Declares a data type or newtype, giving its constructors `data/newtype T a = constrs data/newtype instance T [a] = constrs`

Fields

dd_ND :: NewOrData
dd_ctxt :: LHsContext name

  Context

dd_cType :: Maybe (Located CType)
dd_kindSig :: Maybe (LHsKind name)

  Optional kind signature.

  `(Just k)` for a GADT-style `data`, or `data instance` decl, with explicit kind sig

  Always `Nothing` for H98-syntax decls

dd_cons :: [LConDecl name]

  Data constructors

  For `data T a = T1 | T2 a` the `LConDecl`s all have `ResTyH98`. For `data T a where { T1 :: T a }` the `LConDecls` all have `ResTyGADT`.

dd_derivs :: Maybe (Located [LHsType name])

  Derivings; `Nothing` => not specified, `Just []` => derive exactly what is asked

  These "types" must be of form `forall ab. C ty1 ty2` Typically the foralls and ty args are empty, but they are non-empty for the newtype-deriving case

  - `AnnKeywordId` : `AnnDeriving`, `AnnOpen`,`AnnClose`

Instances

DataId id => Data (HsDataDefn id) |
OutputableBndr name => Outputable (HsDataDefn name) |

## Class or type declarations

data TyClDecl name

A type or class declaration.

Constructors

FamDecl

    type/data family T :: *->*

- `AnnKeywordId` : `AnnType`, `AnnData`, `AnnFamily`,`AnnDcolon`, `AnnWhere`, `AnnOpen`,`AnnDcolon`, `AnnClose`

Fields

tcdFam :: FamilyDecl name

SynDecl

`type` declaration

- `AnnKeywordId` : `AnnType`, `AnnEqual`,

Fields

tcdLName :: Located name

  Type constructor

tcdTyVars :: LHsTyVarBndrs name

  Type variables; for an associated type these include outer binders

tcdRhs :: LHsType name

  RHS of type declaration

tcdFVs :: PostRn name NameSet

DataDecl

`data` declaration

- `AnnKeywordId` : `AnnData`, `AnnFamily`, `AnnNewType`, `AnnNewType`,`AnnDcolon` `AnnWhere`,

Fields

tcdLName :: Located name

  Type constructor

tcdTyVars :: LHsTyVarBndrs name

  Type variables; for an associated type these include outer binders

tcdDataDefn :: HsDataDefn name
tcdFVs :: PostRn name NameSet

ClassDecl

- `AnnKeywordId` : `AnnClass`, `AnnWhere`,`AnnOpen`, `AnnClose`
- The tcdFDs will have `AnnVbar`, `AnnComma` `AnnRarrow`

Fields

tcdCtxt :: LHsContext name

  Context...

tcdLName :: Located name

  Type constructor

tcdTyVars :: LHsTyVarBndrs name

  Type variables; for an associated type these include outer binders

tcdFDs :: [Located (FunDep (Located name))]

  Functional deps

tcdSigs :: [LSig name]

  Methods' signatures

tcdMeths :: LHsBinds name

  Default methods

tcdATs :: [LFamilyDecl name]

  Associated types;

tcdATDefs :: [LTyFamDefltEqn name]

  Associated type defaults

tcdDocs :: [LDocDecl]

  Haddock docs

tcdFVs :: PostRn name NameSet

Instances

DataId id => Data (TyClDecl id) |
OutputableBndr name => Outputable (TyClDecl name) |

type LTyClDecl name = Located (TyClDecl name)

data TyClGroup name

Constructors

TyClGroup |

Fields

group_tyclds :: [LTyClDecl name]
group_roles :: [LRoleAnnotDecl name]

Instances

DataId id => Data (TyClGroup id) |
OutputableBndr name => Outputable (TyClGroup name) |

tyClGroupConcat :: [TyClGroup name] -> [LTyClDecl name]

mkTyClGroup :: [LTyClDecl name] -> TyClGroup name

isClassDecl :: TyClDecl name -> Bool

type class

isDataDecl :: TyClDecl name -> Bool

`True` = argument is a `data`/`newtype` declaration.

isSynDecl :: TyClDecl name -> Bool

type or type instance declaration

tcdName :: TyClDecl name -> name

isFamilyDecl :: TyClDecl name -> Bool

type/data family declaration

isTypeFamilyDecl :: TyClDecl name -> Bool

type family declaration

isDataFamilyDecl :: TyClDecl name -> Bool

data family declaration

isOpenTypeFamilyInfo :: FamilyInfo name -> Bool

open type family info

isClosedTypeFamilyInfo :: FamilyInfo name -> Bool

closed type family info

tyFamInstDeclName :: OutputableBndr name => TyFamInstDecl name -> name

tyFamInstDeclLName :: OutputableBndr name => TyFamInstDecl name -> Located name

countTyClDecls :: [TyClDecl name] -> (Int, Int, Int, Int, Int)

pprTyClDeclFlavour :: TyClDecl a -> SDoc

tyClDeclLName :: TyClDecl name -> Located name

tyClDeclTyVars :: OutputableBndr name => TyClDecl name -> LHsTyVarBndrs name

hsDeclHasCusk :: TyClDecl name -> Bool

Does this declaration have a complete, user-supplied kind signature? See Note [Complete user-supplied kind signatures]

famDeclHasCusk :: FamilyDecl name -> Bool

Does this family declaration have a complete, user-supplied kind signature?

data FamilyDecl name

Constructors

FamilyDecl |

Fields

fdInfo :: FamilyInfo name
fdLName :: Located name
fdTyVars :: LHsTyVarBndrs name
fdKindSig :: Maybe (LHsKind name)

Instances

DataId id => Data (FamilyDecl id) |
OutputableBndr name => Outputable (FamilyDecl name) |

type LFamilyDecl name = Located (FamilyDecl name)

## Instance declarations

data InstDecl name

Constructors

ClsInstD |

Fields

cid_inst :: ClsInstDecl name

DataFamInstD |

Fields

dfid_inst :: DataFamInstDecl name

TyFamInstD |

Fields

tfid_inst :: TyFamInstDecl name

Instances

DataId id => Data (InstDecl id) |
OutputableBndr name => Outputable (InstDecl name) |

type LInstDecl name = Located (InstDecl name)

data NewOrData

Constructors

NewType

    newtype Blah ...

DataType

    data Blah ...

Instances

Eq NewOrData |
Data NewOrData |
Outputable NewOrData |

data FamilyInfo name

Constructors

DataFamily |
OpenTypeFamily |
ClosedTypeFamily [LTyFamInstEqn name] |

Instances

DataId name => Data (FamilyInfo name) |
Outputable (FamilyInfo name) |

data TyFamInstDecl name

Constructors

TyFamInstDecl

- `AnnKeywordId` : `AnnType`, `AnnInstance`,

Fields

tfid_eqn :: LTyFamInstEqn name
tfid_fvs :: PostRn name NameSet

Instances

DataId name => Data (TyFamInstDecl name) |
OutputableBndr name => Outputable (TyFamInstDecl name) |

type LTyFamInstDecl name = Located (TyFamInstDecl name)

instDeclDataFamInsts :: [LInstDecl name] -> [DataFamInstDecl name]

data DataFamInstDecl name

Constructors

DataFamInstDecl

- `AnnKeywordId` : `AnnData`, `AnnNewType`,`AnnInstance`, `AnnDcolon` `AnnWhere`,`AnnOpen`, `AnnClose`

Fields

dfid_tycon :: Located name
dfid_pats :: HsTyPats name
dfid_defn :: HsDataDefn name
dfid_fvs :: PostRn name NameSet

Instances

DataId name => Data (DataFamInstDecl name) |
OutputableBndr name => Outputable (DataFamInstDecl name) |

type LDataFamInstDecl name = Located (DataFamInstDecl name)

pprDataFamInstFlavour :: DataFamInstDecl name -> SDoc

data TyFamEqn name pats

One equation in a type family instance declaration See Note [Type family instance declarations in HsSyn]

Constructors

TyFamEqn

- `AnnKeywordId` : `AnnEqual`

Fields

tfe_tycon :: Located name
tfe_pats :: pats
tfe_rhs :: LHsType name

Instances

(DataId name, Data pats) => Data (TyFamEqn name pats) |

type TyFamInstEqn name = TyFamEqn name (HsTyPats name)

type LTyFamInstEqn name

Arguments

= Located (TyFamInstEqn name) | May have `AnnKeywordId` : `AnnSemi` when in a list

type TyFamDefltEqn name = TyFamEqn name (LHsTyVarBndrs name)

type LTyFamDefltEqn name = Located (TyFamDefltEqn name)

type HsTyPats name

Arguments

= HsWithBndrs name [LHsType name] | Type patterns (with kind and type bndrs) See Note [Family instance declaration binders]

type LClsInstDecl name = Located (ClsInstDecl name)

data ClsInstDecl name

Constructors

ClsInstDecl

- `AnnKeywordId` : `AnnInstance`, `AnnWhere`, `AnnOpen`,`AnnClose`,

Fields

cid_poly_ty :: LHsType name
cid_binds :: LHsBinds name
cid_sigs :: [LSig name]
cid_tyfam_insts :: [LTyFamInstDecl name]
cid_datafam_insts :: [LDataFamInstDecl name]
cid_overlap_mode :: Maybe (Located OverlapMode)
  - `AnnKeywordId` : `AnnOpen`, `AnnClose`,

Instances

DataId id => Data (ClsInstDecl id) |
OutputableBndr name => Outputable (ClsInstDecl name) |

## Standalone deriving declarations

data DerivDecl name

Constructors

DerivDecl |

Fields

deriv_type :: LHsType name
deriv_overlap_mode :: Maybe (Located OverlapMode)
  - `AnnKeywordId` : `AnnOpen`, `AnnClose`, `AnnDeriving`, `AnnInstance`

Instances

DataId name => Data (DerivDecl name) |
OutputableBndr name => Outputable (DerivDecl name) |

type LDerivDecl name = Located (DerivDecl name)

## `RULE` declarations

type LRuleDecls name = Located (RuleDecls name)

data RuleDecls name

Constructors

HsRules |

Fields

rds_src :: SourceText
rds_rules :: [LRuleDecl name]

Instances

DataId name => Data (RuleDecls name) |
OutputableBndr name => Outputable (RuleDecls name) |

data RuleDecl name

Constructors

HsRule (Located RuleName) Activation [LRuleBndr name] (Located (HsExpr name)) (PostRn name NameSet) (Located (HsExpr name)) (PostRn name NameSet)

- `AnnKeywordId` : `AnnOpen`,`AnnTilde`, `AnnVal`, `AnnClose`, `AnnForall`,`AnnDot`, `AnnEqual`,

Instances

DataId name => Data (RuleDecl name) |
OutputableBndr name => Outputable (RuleDecl name) |

type LRuleDecl name = Located (RuleDecl name)

data RuleBndr name

Constructors

RuleBndr (Located name) |

RuleBndrSig (Located name) (HsWithBndrs name (LHsType name))

- `AnnKeywordId` : `AnnOpen`, `AnnDcolon`,`AnnClose`

Instances

DataId name => Data (RuleBndr name) |
OutputableBndr name => Outputable (RuleBndr name) |

type LRuleBndr name = Located (RuleBndr name)

collectRuleBndrSigTys :: [RuleBndr name] -> [HsWithBndrs name (LHsType name)]

flattenRuleDecls :: [LRuleDecls name] -> [LRuleDecl name]

## `VECTORISE` declarations

data VectDecl name

Constructors

HsVect SourceText (Located name) (LHsExpr name)

- `AnnKeywordId` : `AnnOpen`, `AnnEqual`,`AnnClose`

HsNoVect SourceText (Located name)

- `AnnKeywordId` : `AnnOpen`, `AnnClose`

HsVectTypeIn SourceText Bool (Located name) (Maybe (Located name))

- `AnnKeywordId` : `AnnOpen`, `AnnType`,`AnnClose`, `AnnEqual`

HsVectTypeOut Bool TyCon (Maybe TyCon) |

HsVectClassIn SourceText (Located name)

- `AnnKeywordId` : `AnnOpen`, `AnnClass`,`AnnClose`,

HsVectClassOut Class |
HsVectInstIn (LHsType name) |
HsVectInstOut ClsInst |

Instances

DataId name => Data (VectDecl name) |
OutputableBndr name => Outputable (VectDecl name) |

type LVectDecl name = Located (VectDecl name)

lvectDeclName :: NamedThing name => LVectDecl name -> Name

lvectInstDecl :: LVectDecl name -> Bool

## `default` declarations

data DefaultDecl name

Constructors

DefaultDecl [LHsType name]

- `AnnKeywordId`s : `AnnDefault`, `AnnOpen`,`AnnClose`

Instances

DataId name => Data (DefaultDecl name) |
OutputableBndr name => Outputable (DefaultDecl name) |

type LDefaultDecl name = Located (DefaultDecl name)

## Template haskell declaration splice

data SpliceExplicitFlag

Constructors

ExplicitSplice |
ImplicitSplice |

Instances

Data SpliceExplicitFlag |

data SpliceDecl id

Constructors

SpliceDecl (Located (HsSplice id)) SpliceExplicitFlag |

Instances

DataId id => Data (SpliceDecl id) |
OutputableBndr name => Outputable (SpliceDecl name) |

type LSpliceDecl name = Located (SpliceDecl name)

## Foreign function interface declarations

data ForeignDecl name

Constructors

ForeignImport (Located name) (LHsType name) (PostTc name Coercion) ForeignImport |

ForeignExport (Located name) (LHsType name) (PostTc name Coercion) ForeignExport

- `AnnKeywordId` : `AnnForeign`, `AnnImport`,`AnnExport`, `AnnDcolon`

Instances

DataId name => Data (ForeignDecl name) |
OutputableBndr name => Outputable (ForeignDecl name) |

type LForeignDecl name = Located (ForeignDecl name)

data ForeignImport

Constructors

CImport (Located CCallConv) (Located Safety) (Maybe Header) CImportSpec (Located SourceText) |

Instances

Data ForeignImport |
Outputable ForeignImport |

data ForeignExport

Constructors

CExport (Located CExportSpec) (Located SourceText) |

Instances

Data ForeignExport |
Outputable ForeignExport |

noForeignImportCoercionYet :: PlaceHolder

noForeignExportCoercionYet :: PlaceHolder

data CImportSpec

Constructors

CLabel CLabelString |
CFunction CCallTarget |
CWrapper |

Instances

Data CImportSpec |

## Data-constructor declarations

data ConDecl name

    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

- `AnnKeywordId`s : `AnnOpen`, `AnnDotdot`,`AnnCLose`, `AnnEqual`,`AnnVbar`, `AnnDarrow`,`AnnDarrow`, `AnnForall`,`AnnDot`

Constructors

ConDecl |

Fields

con_names :: [Located name]

  Constructor names. This is used for the DataCon itself, and for the user-callable wrapper Id. It is a list to deal with GADT constructors of the form T1, T2, T3 :: payload

con_explicit :: HsExplicitFlag

  Is there an user-written forall? (cf. `HsForAllTy`)

con_qvars :: LHsTyVarBndrs name

  Type variables. Depending on `con_res` this describes the following entities

  - ResTyH98: the constructor's *existential* type variables
  - ResTyGADT: *all* the constructor's quantified type variables

  If con_explicit is Implicit, then con_qvars is irrelevant until after renaming.

con_cxt :: LHsContext name

  The context. This does not include the "stupid theta" which lives only in the `TyData` decl.

con_details :: HsConDeclDetails name

  The main payload

con_res :: ResType (LHsType name)

  Result type of the constructor

con_doc :: Maybe LHsDocString

  A possible Haddock comment.

con_old_rec :: Bool

  TEMPORARY field; True = user has employed now-deprecated syntax for GADT-style record decl C { blah } :: T a b Remove this when we no longer parse this stuff, and hence do not need to report decprecated use

Instances

DataId name => Data (ConDecl name) |
OutputableBndr name => Outputable (ConDecl name) |

type LConDecl name

Arguments

= Located (ConDecl name) | May have `AnnKeywordId` : `AnnSemi` when in a GADT constructor list

data ResType ty

Constructors

ResTyH98 |
ResTyGADT SrcSpan ty |

Instances

Data ty => Data (ResType ty) |
Outputable ty => Outputable (ResType ty) |

type HsConDeclDetails name = HsConDetails (LBangType name) (Located [LConDeclField name])

hsConDeclArgTys :: HsConDeclDetails name -> [LBangType name]

## Document comments

data DocDecl

Constructors

DocCommentNext HsDocString |
DocCommentPrev HsDocString |
DocCommentNamed String HsDocString |
DocGroup Int HsDocString |

Instances

Data DocDecl |
Outputable DocDecl |

type LDocDecl = Located DocDecl

docDeclDoc :: DocDecl -> HsDocString

## Deprecations

data WarnDecl name

Constructors

Warning [Located name] WarningTxt |

Instances

Data name => Data (WarnDecl name) |
OutputableBndr name => Outputable (WarnDecl name) |

type LWarnDecl name = Located (WarnDecl name)

data WarnDecls name

Constructors

Warnings |

Fields

wd_src :: SourceText
wd_warnings :: [LWarnDecl name]

Instances

Data name => Data (WarnDecls name) |
OutputableBndr name => Outputable (WarnDecls name) |

type LWarnDecls name = Located (WarnDecls name)

## Annotations

data AnnDecl name

Constructors

HsAnnotation SourceText (AnnProvenance name) (Located (HsExpr name))

- `AnnKeywordId` : `AnnOpen`, `AnnType` `AnnModule` `AnnClose`

Instances

DataId name => Data (AnnDecl name) |
OutputableBndr name => Outputable (AnnDecl name) |

type LAnnDecl name = Located (AnnDecl name)

data AnnProvenance name

Constructors

ValueAnnProvenance (Located name) |
TypeAnnProvenance (Located name) |
ModuleAnnProvenance |

Instances

Functor AnnProvenance |
Foldable AnnProvenance |
Traversable AnnProvenance |
Data name => Data (AnnProvenance name) |

annProvenanceName_maybe :: AnnProvenance name -> Maybe name

## Role annotations

data RoleAnnotDecl name

Constructors

RoleAnnotDecl (Located name) [Located (Maybe Role)]

- `AnnKeywordId` : `AnnType`, `AnnRole`

Instances

Data name => Data (RoleAnnotDecl name) |
OutputableBndr name => Outputable (RoleAnnotDecl name) |

type LRoleAnnotDecl name = Located (RoleAnnotDecl name)

roleAnnotDeclName :: RoleAnnotDecl name -> name

# Grouping

data HsGroup id

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

Constructors

HsGroup |

Fields

hs_valds :: HsValBinds id
hs_splcds :: [LSpliceDecl id]
hs_tyclds :: [TyClGroup id]
hs_instds :: [LInstDecl id]
hs_derivds :: [LDerivDecl id]
hs_fixds :: [LFixitySig id]
hs_defds :: [LDefaultDecl id]
hs_fords :: [LForeignDecl id]
hs_warnds :: [LWarnDecls id]
hs_annds :: [LAnnDecl id]
hs_ruleds :: [LRuleDecls id]
hs_vects :: [LVectDecl id]
hs_docs :: [LDocDecl]

Instances

DataId id => Data (HsGroup id) |
OutputableBndr name => Outputable (HsGroup name) |

emptyRdrGroup :: HsGroup a

emptyRnGroup :: HsGroup a

appendGroups :: HsGroup a -> HsGroup a -> HsGroup a