ghc-6.12.3: The GHC APISource codeContentsIndex
HsDecls
Contents
Toplevel declarations
Class or type declarations
Instance declarations
Standalone deriving declarations
RULE declarations
default declarations
Top-level template haskell splice
Foreign function interface declarations
Data-constructor declarations
Document comments
Deprecations
Annotations
Grouping
Description

Abstract syntax of global declarations.

Definitions for: TyDecl 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 (WarnDecl id)
| AnnD (AnnDecl id)
| RuleD (RuleDecl id)
| SpliceD (SpliceDecl id)
| DocD DocDecl
type LHsDecl id = Located (HsDecl id)
data TyClDecl name
= ForeignType {
tcdLName :: Located name
tcdExtName :: Maybe FastString
}
| TyFamily {
tcdFlavour :: FamilyFlavour
tcdLName :: Located name
tcdTyVars :: [LHsTyVarBndr name]
tcdKind :: Maybe Kind
}
| TyData {
tcdND :: NewOrData
tcdCtxt :: LHsContext name
tcdLName :: Located name
tcdTyVars :: [LHsTyVarBndr name]
tcdTyPats :: Maybe [LHsType name]
tcdKindSig :: Maybe Kind
tcdCons :: [LConDecl name]
tcdDerivs :: Maybe [LHsType name]
}
| TySynonym {
tcdLName :: Located name
tcdTyVars :: [LHsTyVarBndr name]
tcdTyPats :: Maybe [LHsType name]
tcdSynRhs :: LHsType name
}
| ClassDecl {
tcdCtxt :: LHsContext name
tcdLName :: Located name
tcdTyVars :: [LHsTyVarBndr name]
tcdFDs :: [Located (FunDep name)]
tcdSigs :: [LSig name]
tcdMeths :: LHsBinds name
tcdATs :: [LTyClDecl name]
tcdDocs :: [LDocDecl]
}
type LTyClDecl name = Located (TyClDecl name)
isClassDecl :: TyClDecl name -> Bool
isSynDecl :: TyClDecl name -> Bool
isDataDecl :: TyClDecl name -> Bool
isTypeDecl :: TyClDecl name -> Bool
isFamilyDecl :: TyClDecl name -> Bool
isFamInstDecl :: TyClDecl name -> Bool
tcdName :: TyClDecl name -> name
tyClDeclNames :: Eq name => TyClDecl name -> [Located name]
tyClDeclTyVars :: TyClDecl name -> [LHsTyVarBndr name]
countTyClDecls :: [TyClDecl name] -> (Int, Int, Int, Int, Int, Int)
data InstDecl name = InstDecl (LHsType name) (LHsBinds name) [LSig name] [LTyClDecl name]
type LInstDecl name = Located (InstDecl name)
data NewOrData
= NewType
| DataType
data FamilyFlavour
= TypeFamily
| DataFamily
instDeclATs :: InstDecl name -> [LTyClDecl name]
data DerivDecl name = DerivDecl (LHsType name)
type LDerivDecl name = Located (DerivDecl name)
data RuleDecl name = HsRule RuleName Activation [RuleBndr name] (Located (HsExpr name)) NameSet (Located (HsExpr name)) NameSet
type LRuleDecl name = Located (RuleDecl name)
data RuleBndr name
= RuleBndr (Located name)
| RuleBndrSig (Located name) (LHsType name)
collectRuleBndrSigTys :: [RuleBndr name] -> [LHsType name]
data DefaultDecl name = DefaultDecl [LHsType name]
type LDefaultDecl name = Located (DefaultDecl name)
data SpliceDecl id = SpliceDecl (Located (HsExpr id))
data ForeignDecl name
= ForeignImport (Located name) (LHsType name) ForeignImport
| ForeignExport (Located name) (LHsType name) ForeignExport
type LForeignDecl name = Located (ForeignDecl name)
data ForeignImport = CImport CCallConv Safety FastString CImportSpec
data ForeignExport = CExport CExportSpec
data CImportSpec
= CLabel CLabelString
| CFunction CCallTarget
| CWrapper
data ConDecl name = ConDecl {
con_name :: Located name
con_explicit :: HsExplicitForAll
con_qvars :: [LHsTyVarBndr name]
con_cxt :: LHsContext name
con_details :: HsConDeclDetails name
con_res :: ResType name
con_doc :: Maybe LHsDocString
con_old_rec :: Bool
}
type LConDecl name = Located (ConDecl name)
data ResType name
= ResTyH98
| ResTyGADT (LHsType name)
type HsConDeclDetails name = HsConDetails (LBangType name) [ConDeclField name]
hsConDeclArgTys :: HsConDeclDetails name -> [LBangType name]
hsConDeclsNames :: Eq name => [LConDecl name] -> [Located name]
data DocDecl
= DocCommentNext HsDocString
| DocCommentPrev HsDocString
| DocCommentNamed String HsDocString
| DocGroup Int HsDocString
type LDocDecl = Located DocDecl
docDeclDoc :: DocDecl -> HsDocString
data WarnDecl name = Warning name WarningTxt
type LWarnDecl name = Located (WarnDecl name)
data AnnDecl name = HsAnnotation (AnnProvenance name) (Located (HsExpr name))
type LAnnDecl name = Located (AnnDecl name)
data AnnProvenance name
= ValueAnnProvenance name
| TypeAnnProvenance name
| ModuleAnnProvenance
annProvenanceName_maybe :: AnnProvenance name -> Maybe name
modifyAnnProvenanceNameM :: Monad m => (before -> m after) -> AnnProvenance before -> m (AnnProvenance after)
data HsGroup id = HsGroup {
hs_valds :: HsValBinds id
hs_tyclds :: [LTyClDecl id]
hs_instds :: [LInstDecl id]
hs_derivds :: [LDerivDecl id]
hs_fixds :: [LFixitySig id]
hs_defds :: [LDefaultDecl id]
hs_fords :: [LForeignDecl id]
hs_warnds :: [LWarnDecl id]
hs_annds :: [LAnnDecl id]
hs_ruleds :: [LRuleDecl id]
hs_docs :: [LDocDecl]
}
emptyRdrGroup :: HsGroup a
emptyRnGroup :: HsGroup a
appendGroups :: HsGroup a -> HsGroup a -> HsGroup a
Toplevel declarations
data HsDecl id Source
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 (WarnDecl id)
AnnD (AnnDecl id)
RuleD (RuleDecl id)
SpliceD (SpliceDecl id)
DocD DocDecl
show/hide Instances
type LHsDecl id = Located (HsDecl id)Source
Class or type declarations
data TyClDecl name Source
A type or class declaration.
Constructors
ForeignType
tcdLName :: Located name
tcdExtName :: Maybe FastString
TyFamily
type/data family T :: *->*
tcdFlavour :: FamilyFlavour
tcdLName :: Located name
tcdTyVars :: [LHsTyVarBndr name]
tcdKind :: Maybe Kind
TyDataDeclares a data type or newtype, giving its construcors data/newtype T a = constrs data/newtype instance T [a] = constrs
tcdND :: NewOrData
tcdCtxt :: LHsContext nameContext
tcdLName :: Located name
tcdTyVars :: [LHsTyVarBndr name]
tcdTyPats :: Maybe [LHsType name]

Type patterns.

Just [t1..tn] for data instance T t1..tn = ... in this case tcdTyVars = fv( tcdTyPats ). Nothing for everything else.

tcdKindSig :: Maybe Kind

Optional kind signature.

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

tcdCons :: [LConDecl name]

Data constructors

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

tcdDerivs :: Maybe [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

TySynonym
tcdLName :: Located name
tcdTyVars :: [LHsTyVarBndr name]
tcdTyPats :: Maybe [LHsType name]

Type patterns.

Just [t1..tn] for data instance T t1..tn = ... in this case tcdTyVars = fv( tcdTyPats ). Nothing for everything else.

tcdSynRhs :: LHsType namesynonym expansion
ClassDecl
tcdCtxt :: LHsContext nameContext
tcdLName :: Located name
tcdTyVars :: [LHsTyVarBndr name]
tcdFDs :: [Located (FunDep name)]Functional deps
tcdSigs :: [LSig name]Methods' signatures
tcdMeths :: LHsBinds nameDefault methods
tcdATs :: [LTyClDecl name]Associated types; ie only TyFamily and TySynonym; the latter for defaults
tcdDocs :: [LDocDecl]Haddock docs
show/hide Instances
type LTyClDecl name = Located (TyClDecl name)Source
isClassDecl :: TyClDecl name -> BoolSource
type class
isSynDecl :: TyClDecl name -> BoolSource
vanilla Haskell type synonym (ie, not a type instance)
isDataDecl :: TyClDecl name -> BoolSource
True = argument is a data/newtype or data/newtype instance declaration.
isTypeDecl :: TyClDecl name -> BoolSource
type or type instance declaration
isFamilyDecl :: TyClDecl name -> BoolSource
type family declaration
isFamInstDecl :: TyClDecl name -> BoolSource
family instance (types, newtypes, and data types)
tcdName :: TyClDecl name -> nameSource
tyClDeclNames :: Eq name => TyClDecl name -> [Located name]Source
Returns all the binding names of the decl, along with their SrcLocs. The first one is guaranteed to be the name of the decl. For record fields mentioned in multiple constructors, the SrcLoc will be from the first occurence. We use the equality to filter out duplicate field names
tyClDeclTyVars :: TyClDecl name -> [LHsTyVarBndr name]Source
countTyClDecls :: [TyClDecl name] -> (Int, Int, Int, Int, Int, Int)Source
Instance declarations
data InstDecl name Source
Constructors
InstDecl (LHsType name) (LHsBinds name) [LSig name] [LTyClDecl name]
show/hide Instances
type LInstDecl name = Located (InstDecl name)Source
data NewOrData Source
Constructors
NewType
newtype Blah ...
DataType
data Blah ...
show/hide Instances
data FamilyFlavour Source
Constructors
TypeFamily
type family ...
DataFamily
data family ...
instDeclATs :: InstDecl name -> [LTyClDecl name]Source
Standalone deriving declarations
data DerivDecl name Source
Constructors
DerivDecl (LHsType name)
show/hide Instances
type LDerivDecl name = Located (DerivDecl name)Source
RULE declarations
data RuleDecl name Source
Constructors
HsRule RuleName Activation [RuleBndr name] (Located (HsExpr name)) NameSet (Located (HsExpr name)) NameSet
show/hide Instances
type LRuleDecl name = Located (RuleDecl name)Source
data RuleBndr name Source
Constructors
RuleBndr (Located name)
RuleBndrSig (Located name) (LHsType name)
show/hide Instances
collectRuleBndrSigTys :: [RuleBndr name] -> [LHsType name]Source
default declarations
data DefaultDecl name Source
Constructors
DefaultDecl [LHsType name]
show/hide Instances
type LDefaultDecl name = Located (DefaultDecl name)Source
Top-level template haskell splice
data SpliceDecl id Source
Constructors
SpliceDecl (Located (HsExpr id))
show/hide Instances
Foreign function interface declarations
data ForeignDecl name Source
Constructors
ForeignImport (Located name) (LHsType name) ForeignImport
ForeignExport (Located name) (LHsType name) ForeignExport
show/hide Instances
type LForeignDecl name = Located (ForeignDecl name)Source
data ForeignImport Source
Constructors
CImport CCallConv Safety FastString CImportSpec
show/hide Instances
data ForeignExport Source
Constructors
CExport CExportSpec
show/hide Instances
data CImportSpec Source
Constructors
CLabel CLabelString
CFunction CCallTarget
CWrapper
Data-constructor declarations
data ConDecl name Source
Constructors
ConDecl
con_name :: Located nameConstructor name. This is used for the DataCon itself, and for the user-callable wrapper Id.
con_explicit :: HsExplicitForAllIs there an user-written forall? (cf. HsForAllTy)
con_qvars :: [LHsTyVarBndr name]

Type variables. Depending on con_res this describes the follewing entities

  • ResTyH98: the constructor's *existential* type variables - ResTyGADT: *all* the constructor's quantified type variables
con_cxt :: LHsContext nameThe context. This does not include the "stupid theta" which lives only in the TyData decl.
con_details :: HsConDeclDetails nameThe main payload
con_res :: ResType nameResult type of the constructor
con_doc :: Maybe LHsDocStringA possible Haddock comment.
con_old_rec :: BoolTEMPORARY 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
show/hide Instances
type LConDecl name = Located (ConDecl name)Source
data ResType name Source
Constructors
ResTyH98
ResTyGADT (LHsType name)
show/hide Instances
type HsConDeclDetails name = HsConDetails (LBangType name) [ConDeclField name]Source
hsConDeclArgTys :: HsConDeclDetails name -> [LBangType name]Source
hsConDeclsNames :: Eq name => [LConDecl name] -> [Located name]Source
Document comments
data DocDecl Source
Constructors
DocCommentNext HsDocString
DocCommentPrev HsDocString
DocCommentNamed String HsDocString
DocGroup Int HsDocString
show/hide Instances
type LDocDecl = Located DocDeclSource
docDeclDoc :: DocDecl -> HsDocStringSource
Deprecations
data WarnDecl name Source
Constructors
Warning name WarningTxt
show/hide Instances
type LWarnDecl name = Located (WarnDecl name)Source
Annotations
data AnnDecl name Source
Constructors
HsAnnotation (AnnProvenance name) (Located (HsExpr name))
show/hide Instances
type LAnnDecl name = Located (AnnDecl name)Source
data AnnProvenance name Source
Constructors
ValueAnnProvenance name
TypeAnnProvenance name
ModuleAnnProvenance
annProvenanceName_maybe :: AnnProvenance name -> Maybe nameSource
modifyAnnProvenanceNameM :: Monad m => (before -> m after) -> AnnProvenance before -> m (AnnProvenance after)Source
Grouping
data HsGroup id Source
A HsDecl is categorised into a HsGroup before being fed to the renamer.
Constructors
HsGroup
hs_valds :: HsValBinds id
hs_tyclds :: [LTyClDecl id]
hs_instds :: [LInstDecl id]
hs_derivds :: [LDerivDecl id]
hs_fixds :: [LFixitySig id]
hs_defds :: [LDefaultDecl id]
hs_fords :: [LForeignDecl id]
hs_warnds :: [LWarnDecl id]
hs_annds :: [LAnnDecl id]
hs_ruleds :: [LRuleDecl id]
hs_docs :: [LDocDecl]
show/hide Instances
emptyRdrGroup :: HsGroup aSource
emptyRnGroup :: HsGroup aSource
appendGroups :: HsGroup a -> HsGroup a -> HsGroup aSource
Produced by Haddock version 2.6.1