Copyright | (c) Niklas Broberg 2004-2009, (c) The GHC Team, 1997-2000 |
---|---|
License | BSD-style (see the file LICENSE.txt) |
Maintainer | Niklas Broberg, d00nibro@chalmers.se |
Stability | stable |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell98 |
A suite of datatypes describing the abstract syntax of Haskell 98 http://www.haskell.org/onlinereport/ plus registered extensions, including:
- multi-parameter type classes with functional dependencies (MultiParamTypeClasses, FunctionalDependencies)
- parameters of type class assertions are unrestricted (FlexibleContexts)
forall
types as universal and existential quantification (RankNTypes, ExistentialQuantification, etc)- pattern guards (PatternGuards)
- implicit parameters (ImplicitParameters)
- generalised algebraic data types (GADTs)
- template haskell (TemplateHaskell)
- empty data type declarations (EmptyDataDecls)
- unboxed tuples (UnboxedTuples)
- regular patterns (RegularPatterns)
- HSP-style XML expressions and patterns (XmlSyntax)
- data Module = Module SrcLoc ModuleName [ModulePragma] (Maybe WarningText) (Maybe [ExportSpec]) [ImportDecl] [Decl]
- data WarningText
- data ExportSpec
- data ImportDecl = ImportDecl {
- importLoc :: SrcLoc
- importModule :: ModuleName
- importQualified :: Bool
- importSrc :: Bool
- importSafe :: Bool
- importPkg :: Maybe String
- importAs :: Maybe ModuleName
- importSpecs :: Maybe (Bool, [ImportSpec])
- data ImportSpec
- data Assoc
- data Namespace
- data Decl
- = TypeDecl SrcLoc Name [TyVarBind] Type
- | TypeFamDecl SrcLoc Name [TyVarBind] (Maybe Kind)
- | ClosedTypeFamDecl SrcLoc Name [TyVarBind] (Maybe Kind) [TypeEqn]
- | DataDecl SrcLoc DataOrNew Context Name [TyVarBind] [QualConDecl] [Deriving]
- | GDataDecl SrcLoc DataOrNew Context Name [TyVarBind] (Maybe Kind) [GadtDecl] [Deriving]
- | DataFamDecl SrcLoc Context Name [TyVarBind] (Maybe Kind)
- | TypeInsDecl SrcLoc Type Type
- | DataInsDecl SrcLoc DataOrNew Type [QualConDecl] [Deriving]
- | GDataInsDecl SrcLoc DataOrNew Type (Maybe Kind) [GadtDecl] [Deriving]
- | ClassDecl SrcLoc Context Name [TyVarBind] [FunDep] [ClassDecl]
- | InstDecl SrcLoc (Maybe Overlap) [TyVarBind] Context QName [Type] [InstDecl]
- | DerivDecl SrcLoc (Maybe Overlap) [TyVarBind] Context QName [Type]
- | InfixDecl SrcLoc Assoc Int [Op]
- | DefaultDecl SrcLoc [Type]
- | SpliceDecl SrcLoc Exp
- | TypeSig SrcLoc [Name] Type
- | FunBind [Match]
- | PatBind SrcLoc Pat Rhs Binds
- | ForImp SrcLoc CallConv Safety String Name Type
- | ForExp SrcLoc CallConv String Name Type
- | RulePragmaDecl SrcLoc [Rule]
- | DeprPragmaDecl SrcLoc [([Name], String)]
- | WarnPragmaDecl SrcLoc [([Name], String)]
- | InlineSig SrcLoc Bool Activation QName
- | InlineConlikeSig SrcLoc Activation QName
- | SpecSig SrcLoc Activation QName [Type]
- | SpecInlineSig SrcLoc Bool Activation QName [Type]
- | InstSig SrcLoc [TyVarBind] Context QName [Type]
- | AnnPragma SrcLoc Annotation
- | MinimalPragma SrcLoc (Maybe BooleanFormula)
- data Binds
- data IPBind = IPBind SrcLoc IPName Exp
- data ClassDecl
- data InstDecl
- type Deriving = (QName, [Type])
- data DataOrNew
- data ConDecl
- data QualConDecl = QualConDecl SrcLoc [TyVarBind] Context ConDecl
- data GadtDecl = GadtDecl SrcLoc Name [([Name], Type)] Type
- data BangType
- data Match = Match SrcLoc Name [Pat] (Maybe Type) Rhs Binds
- data Rhs
- data GuardedRhs = GuardedRhs SrcLoc [Stmt] Exp
- type Context = [Asst]
- data FunDep = FunDep [Name] [Name]
- data Asst
- data Type
- data Boxed
- data Kind
- data TyVarBind
- data Promoted
- data TypeEqn = TypeEqn Type Type
- data Exp
- = Var QName
- | IPVar IPName
- | Con QName
- | Lit Literal
- | InfixApp Exp QOp Exp
- | App Exp Exp
- | NegApp Exp
- | Lambda SrcLoc [Pat] Exp
- | Let Binds Exp
- | If Exp Exp Exp
- | MultiIf [GuardedRhs]
- | Case Exp [Alt]
- | Do [Stmt]
- | MDo [Stmt]
- | Tuple Boxed [Exp]
- | TupleSection Boxed [Maybe Exp]
- | List [Exp]
- | ParArray [Exp]
- | Paren Exp
- | LeftSection Exp QOp
- | RightSection QOp Exp
- | RecConstr QName [FieldUpdate]
- | RecUpdate Exp [FieldUpdate]
- | EnumFrom Exp
- | EnumFromTo Exp Exp
- | EnumFromThen Exp Exp
- | EnumFromThenTo Exp Exp Exp
- | ParArrayFromTo Exp Exp
- | ParArrayFromThenTo Exp Exp Exp
- | ListComp Exp [QualStmt]
- | ParComp Exp [[QualStmt]]
- | ParArrayComp Exp [[QualStmt]]
- | ExpTypeSig SrcLoc Exp Type
- | VarQuote QName
- | TypQuote QName
- | BracketExp Bracket
- | SpliceExp Splice
- | QuasiQuote String String
- | XTag SrcLoc XName [XAttr] (Maybe Exp) [Exp]
- | XETag SrcLoc XName [XAttr] (Maybe Exp)
- | XPcdata String
- | XExpTag Exp
- | XChildTag SrcLoc [Exp]
- | CorePragma String Exp
- | SCCPragma String Exp
- | GenPragma String (Int, Int) (Int, Int) Exp
- | Proc SrcLoc Pat Exp
- | LeftArrApp Exp Exp
- | RightArrApp Exp Exp
- | LeftArrHighApp Exp Exp
- | RightArrHighApp Exp Exp
- | LCase [Alt]
- data Stmt
- data QualStmt
- data FieldUpdate
- data Alt = Alt SrcLoc Pat Rhs Binds
- data XAttr = XAttr XName Exp
- data Pat
- = PVar Name
- | PLit Sign Literal
- | PNPlusK Name Integer
- | PInfixApp Pat QName Pat
- | PApp QName [Pat]
- | PTuple Boxed [Pat]
- | PList [Pat]
- | PParen Pat
- | PRec QName [PatField]
- | PAsPat Name Pat
- | PWildCard
- | PIrrPat Pat
- | PatTypeSig SrcLoc Pat Type
- | PViewPat Exp Pat
- | PRPat [RPat]
- | PXTag SrcLoc XName [PXAttr] (Maybe Pat) [Pat]
- | PXETag SrcLoc XName [PXAttr] (Maybe Pat)
- | PXPcdata String
- | PXPatTag Pat
- | PXRPats [RPat]
- | PQuasiQuote String String
- | PBangPat Pat
- data PatField
- data PXAttr = PXAttr XName Pat
- data RPat
- data RPatOp
- data Literal
- data Sign
- newtype ModuleName = ModuleName String
- data QName
- data Name
- data QOp
- data Op
- data SpecialCon
- data CName
- data IPName
- data XName
- data Bracket
- = ExpBracket Exp
- | PatBracket Pat
- | TypeBracket Type
- | DeclBracket [Decl]
- data Splice
- data Safety
- data CallConv
- data ModulePragma
- data Tool
- data Overlap
- data Rule = Rule String Activation (Maybe [RuleVar]) Exp Exp
- data RuleVar
- data Activation
- data Annotation
- data BooleanFormula
- prelude_mod :: ModuleName
- main_mod :: ModuleName
- main_name :: Name
- unit_con_name :: QName
- tuple_con_name :: Boxed -> Int -> QName
- list_cons_name :: QName
- unboxed_singleton_con_name :: QName
- unit_con :: Exp
- tuple_con :: Boxed -> Int -> Exp
- unboxed_singleton_con :: Exp
- as_name :: Name
- qualified_name :: Name
- hiding_name :: Name
- minus_name :: Name
- bang_name :: Name
- dot_name :: Name
- star_name :: Name
- export_name :: Name
- safe_name :: Name
- unsafe_name :: Name
- interruptible_name :: Name
- threadsafe_name :: Name
- stdcall_name :: Name
- ccall_name :: Name
- cplusplus_name :: Name
- dotnet_name :: Name
- jvm_name :: Name
- js_name :: Name
- capi_name :: Name
- forall_name :: Name
- family_name :: Name
- unit_tycon_name :: QName
- fun_tycon_name :: QName
- list_tycon_name :: QName
- tuple_tycon_name :: Boxed -> Int -> QName
- unboxed_singleton_tycon_name :: QName
- unit_tycon :: Type
- fun_tycon :: Type
- list_tycon :: Type
- tuple_tycon :: Boxed -> Int -> Type
- unboxed_singleton_tycon :: Type
- data SrcLoc = SrcLoc {}
Modules
A complete Haskell source module.
Module SrcLoc ModuleName [ModulePragma] (Maybe WarningText) (Maybe [ExportSpec]) [ImportDecl] [Decl] |
data WarningText Source
Warning text to optionally use in the module header of e.g. a deprecated module.
data ExportSpec Source
An item in a module's export specification.
EVar Namespace QName | variable. |
EAbs QName |
|
EThingAll QName |
|
EThingWith QName [CName] |
|
EModuleContents ModuleName |
|
data ImportDecl Source
An import declaration.
ImportDecl | |
|
data ImportSpec Source
An import specification, representing a single explicit item imported (or hidden) from a module.
IVar Namespace Name | variable. |
IAbs Name |
|
IThingAll Name |
|
IThingWith Name [CName] |
|
Associativity of an operator.
AssocNone | non-associative operator (declared with |
AssocLeft | left-associative operator (declared with |
AssocRight | right-associative operator (declared with |
Namespaces for imports/exports.
Declarations
A top-level declaration.
A binding group inside a let
or where
clause.
A binding of an implicit parameter.
Type classes and instances
Declarations inside a class declaration.
ClsDecl Decl | ordinary declaration |
ClsDataFam SrcLoc Context Name [TyVarBind] (Maybe Kind) | declaration of an associated data type |
ClsTyFam SrcLoc Name [TyVarBind] (Maybe Kind) | declaration of an associated type synonym |
ClsTyDef SrcLoc Type Type | default choice for an associated type synonym |
ClsDefSig SrcLoc Name Type | default signature |
Declarations inside an instance declaration.
type Deriving = (QName, [Type]) Source
A single derived instance, which may have arguments since it may be a MPTC.
Data type declarations
A flag stating whether a declaration is a data or newtype declaration.
Declaration of an ordinary data constructor.
data QualConDecl Source
A single constructor declaration within a data type declaration, which may have an existential quantification binding.
A single constructor declaration in a GADT data type declaration.
The type of a constructor argument or field, optionally including a strictness annotation.
BangedTy | strict component, marked with " |
UnpackedTy | unboxed component, marked with an UNPACK pragma |
Function bindings
Clauses of a function binding.
The right hand side of a function binding, pattern binding, or a case alternative.
UnGuardedRhs Exp | unguarded right hand side (exp) |
GuardedRhss [GuardedRhs] | guarded right hand side (gdrhs) |
data GuardedRhs Source
A guarded right hand side |
stmts =
exp, or |
stmts ->
exp
for case alternatives.
The guard is a series of statements when using pattern guards,
otherwise it will be a single qualifier expression.
Class Assertions and Contexts
A functional dependency, given on the form l1 l2 ... ln -> r2 r3 .. rn
Class assertions. In Haskell 98, the argument would be a tyvar, but this definition allows multiple parameters, and allows them to be types. Also extended with support for implicit parameters and equality constraints.
ClassA QName [Type] | ordinary class assertion |
VarA Name | constraint kind assertion, |
InfixA Type QName Type | class assertion where the class name is given infix |
IParam IPName Type | implicit parameter assertion |
EqualP Type Type | type equality constraint |
ParenA Asst | parenthesised class assertion |
Types
A type qualified with a context. An unqualified type has an empty context.
TyForall (Maybe [TyVarBind]) Context Type | qualified type |
TyFun Type Type | function type |
TyTuple Boxed [Type] | tuple type, possibly boxed |
TyList Type | list syntax, e.g. [a], as opposed to [] a |
TyParArray Type | parallel array syntax, e.g. [:a:] |
TyApp Type Type | application of a type constructor |
TyVar Name | type variable |
TyCon QName | named type or type constructor |
TyParen Type | type surrounded by parentheses |
TyInfix Type QName Type | infix type constructor |
TyKind Type Kind | type with explicit kind signature |
TyPromoted Promoted | promoted data type (-XDataKinds) |
TyEquals Type Type | type equality predicate enabled by ConstraintKinds |
TySplice Splice | template haskell splice type |
TyBang BangType Type | Strict type marked with " |
Flag denoting whether a tuple is boxed or unboxed.
An explicit kind annotation.
KindStar |
|
KindBang |
|
KindFn Kind Kind |
|
KindParen Kind | a kind surrounded by parentheses |
KindVar QName | a kind variable (as of yet unsupported by compilers) |
KindApp Kind Kind | k1 k2 |
KindTuple [Kind] |
|
KindList [Kind] |
|
A type variable declaration, optionally with an explicit kind annotation.
KindedVar Name Kind | variable binding with kind annotation |
UnkindedVar Name | ordinary variable binding |
A type equation of the form rhs = lhs
used in closed type families.
Expressions
Haskell expressions.
Var QName | variable |
IPVar IPName | implicit parameter variable |
Con QName | data constructor |
Lit Literal | literal constant |
InfixApp Exp QOp Exp | infix application |
App Exp Exp | ordinary application |
NegApp Exp | negation expression |
Lambda SrcLoc [Pat] Exp | lambda expression |
Let Binds Exp | local declarations with |
If Exp Exp Exp |
|
MultiIf [GuardedRhs] |
|
Case Exp [Alt] |
|
Do [Stmt] |
|
MDo [Stmt] |
|
Tuple Boxed [Exp] | tuple expression |
TupleSection Boxed [Maybe Exp] | tuple section expression, e.g. |
List [Exp] | list expression |
ParArray [Exp] | parallel array expression |
Paren Exp | parenthesised expression |
LeftSection Exp QOp | left section |
RightSection QOp Exp | right section |
RecConstr QName [FieldUpdate] | record construction expression |
RecUpdate Exp [FieldUpdate] | record update expression |
EnumFrom Exp | unbounded arithmetic sequence,
incrementing by 1: |
EnumFromTo Exp Exp | bounded arithmetic sequence,
incrementing by 1 |
EnumFromThen Exp Exp | unbounded arithmetic sequence,
with first two elements given |
EnumFromThenTo Exp Exp Exp | bounded arithmetic sequence,
with first two elements given |
ParArrayFromTo Exp Exp | bounded arithmetic sequence,
incrementing by 1 |
ParArrayFromThenTo Exp Exp Exp | bounded arithmetic sequence,
with first two elements given |
ListComp Exp [QualStmt] | ordinary list comprehension |
ParComp Exp [[QualStmt]] | parallel list comprehension |
ParArrayComp Exp [[QualStmt]] | parallel array comprehension |
ExpTypeSig SrcLoc Exp Type | expression with explicit type signature |
VarQuote QName |
|
TypQuote QName |
|
BracketExp Bracket | template haskell bracket expression |
SpliceExp Splice | template haskell splice expression |
QuasiQuote String String | quasi-quotaion: |
XTag SrcLoc XName [XAttr] (Maybe Exp) [Exp] | xml element, with attributes and children |
XETag SrcLoc XName [XAttr] (Maybe Exp) | empty xml element, with attributes |
XPcdata String | PCDATA child element |
XExpTag Exp | escaped haskell expression inside xml |
XChildTag SrcLoc [Exp] | children of an xml element |
CorePragma String Exp | CORE pragma |
SCCPragma String Exp | SCC pragma |
GenPragma String (Int, Int) (Int, Int) Exp | GENERATED pragma |
Proc SrcLoc Pat Exp | arrows proc: |
LeftArrApp Exp Exp | arrow application (from left): exp |
RightArrApp Exp Exp | arrow application (from right): exp |
LeftArrHighApp Exp Exp | higher-order arrow application (from left): exp |
RightArrHighApp Exp Exp | higher-order arrow application (from right): exp |
LCase [Alt] |
|
A statement, representing both a stmt in a do
-expression,
an ordinary qual in a list comprehension, as well as a stmt
in a pattern guard.
A general transqual in a list comprehension, which could potentially be a transform of the kind enabled by TransformListComp.
data FieldUpdate Source
An fbind in a labeled construction or update expression.
FieldUpdate QName Exp | ordinary label-expresion pair |
FieldPun QName | record field pun |
FieldWildcard | record field wildcard |
An alt alternative in a case
expression.
An xml attribute, which is a name-expression pair.
Patterns
A pattern, to be matched against a value.
PVar Name | variable |
PLit Sign Literal | literal constant |
PNPlusK Name Integer | n+k pattern |
PInfixApp Pat QName Pat | pattern with an infix data constructor |
PApp QName [Pat] | data constructor and argument patterns |
PTuple Boxed [Pat] | tuple pattern |
PList [Pat] | list pattern |
PParen Pat | parenthesized pattern |
PRec QName [PatField] | labelled pattern, record style |
PAsPat Name Pat |
|
PWildCard | wildcard pattern: |
PIrrPat Pat | irrefutable pattern: |
PatTypeSig SrcLoc Pat Type | pattern with type signature |
PViewPat Exp Pat | view patterns of the form |
PRPat [RPat] | regular list pattern |
PXTag SrcLoc XName [PXAttr] (Maybe Pat) [Pat] | XML element pattern |
PXETag SrcLoc XName [PXAttr] (Maybe Pat) | XML singleton element pattern |
PXPcdata String | XML PCDATA pattern |
PXPatTag Pat | XML embedded pattern |
PXRPats [RPat] | XML regular list pattern |
PQuasiQuote String String | quasi quote patter: |
PBangPat Pat | strict (bang) pattern: |
An fpat in a labeled record pattern.
An XML attribute in a pattern.
An entity in a regular pattern.
RPOp RPat RPatOp | operator pattern, e.g. pat* |
RPEither RPat RPat | choice pattern, e.g. (1 | 2) |
RPSeq [RPat] | sequence pattern, e.g. (| 1, 2, 3 |) |
RPGuard Pat [Stmt] | guarded pattern, e.g. (| p | p < 3 |) |
RPCAs Name RPat | non-linear variable binding, e.g. (foo@:(1 | 2))* |
RPAs Name RPat | linear variable binding, e.g. foo@(1 | 2) |
RPParen RPat | parenthesised pattern, e.g. (2*) |
RPPat Pat | an ordinary pattern |
A regular pattern operator.
Literals
literal
Values of this type hold the abstract value of the literal, not the
precise string representation used. For example, 10
, 0o12
and 0xa
have the same representation.
Char Char | character literal |
String String | string literal |
Int Integer | integer literal |
Frac Rational | floating point literal |
PrimInt Integer | unboxed integer literal |
PrimWord Integer | unboxed word literal |
PrimFloat Rational | unboxed float literal |
PrimDouble Rational | unboxed double literal |
PrimChar Char | unboxed character literal |
PrimString String | unboxed string literal |
An indication whether a literal pattern has been negated or not.
Variables, Constructors and Operators
newtype ModuleName Source
The name of a Haskell module.
This type is used to represent qualified variables, and also qualified constructors.
Qual ModuleName Name | name qualified with a module name |
UnQual Name | unqualified local name |
Special SpecialCon | built-in constructor with special syntax |
This type is used to represent variables, and also constructors.
Possibly qualified infix operators (qop), appearing in expressions.
Operators appearing in infix
declarations are never qualified.
data SpecialCon Source
Constructors with special syntax. These names are never qualified, and always refer to builtin type or data constructors.
A name (cname) of a component of a class or data type in an import
or export specification.
An implicit parameter name.
The name of an xml element or attribute, possibly qualified with a namespace.
Template Haskell
A template haskell bracket expression.
ExpBracket Exp | expression bracket: |
PatBracket Pat | pattern bracket: |
TypeBracket Type | type bracket: |
DeclBracket [Decl] | declaration bracket: |
A template haskell splice expression
IdSplice String | variable splice: |
ParenSplice Exp | parenthesised expression splice: |
FFI
The safety of a foreign function call.
The calling convention of a foreign function call.
Pragmas
data ModulePragma Source
A top level options pragma, preceding the module header.
LanguagePragma SrcLoc [Name] | LANGUAGE pragma |
OptionsPragma SrcLoc (Maybe Tool) String | OPTIONS pragma, possibly qualified with a tool, e.g. OPTIONS_GHC |
AnnModulePragma SrcLoc Annotation | ANN pragma with module scope |
Recognised tools for OPTIONS pragmas.
Recognised overlaps for overlap pragmas.
NoOverlap | NO_OVERLAP pragma |
Overlap | OVERLAP pragma |
Incoherent | INCOHERENT pragma |
The body of a RULES pragma.
Variables used in a RULES pragma, optionally annotated with types
data Activation Source
Activation clause of a RULES pragma.
data Annotation Source
An annotation through an ANN pragma.
data BooleanFormula Source
A boolean formula for MINIMAL pragmas.
VarFormula Name | A variable. |
AndFormula [BooleanFormula] | And boolean formulas. |
OrFormula [BooleanFormula] | Or boolean formulas. |
ParenFormula BooleanFormula | Parenthesized boolean formulas. |
Builtin names
Modules
Main function of a program
Constructors
tuple_con_name :: Boxed -> Int -> QName Source
Special identifiers
minus_name :: Name Source
ccall_name :: Name Source
Type constructors
tuple_tycon_name :: Boxed -> Int -> QName Source
unit_tycon :: Type Source
list_tycon :: Type Source
tuple_tycon :: Boxed -> Int -> Type Source