Portability | portable |
---|---|
Stability | stable |
Maintainer | Niklas Broberg, d00nibro@chalmers.se |
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
- = EVar QName
- | EAbs QName
- | EThingAll QName
- | EThingWith QName [CName]
- | EModuleContents ModuleName
- data ImportDecl = ImportDecl {
- importLoc :: SrcLoc
- importModule :: ModuleName
- importQualified :: Bool
- importSrc :: Bool
- importPkg :: Maybe String
- importAs :: Maybe ModuleName
- importSpecs :: Maybe (Bool, [ImportSpec])
- data ImportSpec
- data Assoc
- = AssocNone
- | AssocLeft
- | AssocRight
- data Decl
- = TypeDecl SrcLoc Name [TyVarBind] Type
- | TypeFamDecl SrcLoc Name [TyVarBind] (Maybe Kind)
- | 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 Context QName [Type] [InstDecl]
- | DerivDecl SrcLoc Context QName [Type]
- | InfixDecl SrcLoc Assoc Int [Op]
- | DefaultDecl SrcLoc [Type]
- | SpliceDecl SrcLoc Exp
- | TypeSig SrcLoc [Name] Type
- | FunBind [Match]
- | PatBind SrcLoc Pat (Maybe Type) 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 QName [Type]
- | SpecInlineSig SrcLoc Bool Activation QName [Type]
- | InstSig SrcLoc Context QName [Type]
- | AnnPragma SrcLoc Annotation
- 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 Type
- data BangType
- = BangedTy Type
- | UnBangedTy Type
- | UnpackedTy Type
- data Match = Match SrcLoc Name [Pat] (Maybe Type) Rhs Binds
- data Rhs
- = UnGuardedRhs Exp
- | GuardedRhss [GuardedRhs]
- data GuardedRhs = GuardedRhs SrcLoc [Stmt] Exp
- type Context = [Asst]
- data FunDep = FunDep [Name] [Name]
- data Asst
- data Type
- data Boxed
- data Kind
- data TyVarBind
- = KindedVar Name Kind
- | UnkindedVar Name
- 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
- | Case Exp [Alt]
- | Do [Stmt]
- | MDo [Stmt]
- | Tuple [Exp]
- | TupleSection [Maybe Exp]
- | List [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
- | ListComp Exp [QualStmt]
- | ParComp 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
- | 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
- data Stmt
- data QualStmt
- data FieldUpdate
- = FieldUpdate QName Exp
- | FieldPun Name
- | FieldWildcard
- data Alt = Alt SrcLoc Pat GuardedAlts Binds
- data GuardedAlts
- = UnGuardedAlt Exp
- | GuardedAlts [GuardedAlt]
- data GuardedAlt = GuardedAlt SrcLoc [Stmt] Exp
- data XAttr = XAttr XName Exp
- data Pat
- = PVar Name
- | PLit Literal
- | PNeg Pat
- | PNPlusK Name Integer
- | PInfixApp Pat QName Pat
- | PApp QName [Pat]
- | PTuple [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]
- | PExplTypeArg QName Type
- | PQuasiQuote String String
- | PBangPat Pat
- data PatField
- data PXAttr = PXAttr XName Pat
- data RPat
- data RPatOp
- data Literal
- newtype ModuleName = ModuleName String
- data QName
- = Qual ModuleName Name
- | UnQual Name
- | Special SpecialCon
- 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
- = IdSplice String
- | ParenSplice Exp
- data Safety
- data CallConv
- data ModulePragma
- data Tool
- data Rule = Rule String Activation (Maybe [RuleVar]) Exp Exp
- data RuleVar
- = RuleVar Name
- | TypedRuleVar Name Type
- data Activation
- = AlwaysActive
- | ActiveFrom Int
- | ActiveUntil Int
- data Annotation
- 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
- threadsafe_name :: Name
- stdcall_name :: Name
- ccall_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 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 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 |
Declarations
A top-level declaration.
TypeDecl SrcLoc Name [TyVarBind] Type | A type declaration |
TypeFamDecl SrcLoc Name [TyVarBind] (Maybe Kind) | A type family declaration |
DataDecl SrcLoc DataOrNew Context Name [TyVarBind] [QualConDecl] [Deriving] | A data OR newtype declaration |
GDataDecl SrcLoc DataOrNew Context Name [TyVarBind] (Maybe Kind) [GadtDecl] [Deriving] | A data OR newtype declaration, GADT style |
DataFamDecl SrcLoc Context Name [TyVarBind] (Maybe Kind) | A data family declaration |
TypeInsDecl SrcLoc Type Type | A type family instance declaration |
DataInsDecl SrcLoc DataOrNew Type [QualConDecl] [Deriving] | A data family instance declaration |
GDataInsDecl SrcLoc DataOrNew Type (Maybe Kind) [GadtDecl] [Deriving] | A data family instance declaration, GADT style |
ClassDecl SrcLoc Context Name [TyVarBind] [FunDep] [ClassDecl] | A declaration of a type class |
InstDecl SrcLoc Context QName [Type] [InstDecl] | An declaration of a type class instance |
DerivDecl SrcLoc Context QName [Type] | A standalone deriving declaration |
InfixDecl SrcLoc Assoc Int [Op] | A declaration of operator fixity |
DefaultDecl SrcLoc [Type] | A declaration of default types |
SpliceDecl SrcLoc Exp | A Template Haskell splicing declaration |
TypeSig SrcLoc [Name] Type | A type signature declaration |
FunBind [Match] | A set of function binding clauses |
PatBind SrcLoc Pat (Maybe Type) Rhs Binds | A pattern binding |
ForImp SrcLoc CallConv Safety String Name Type | A foreign import declaration |
ForExp SrcLoc CallConv String Name Type | A foreign export declaration |
RulePragmaDecl SrcLoc [Rule] | A RULES pragma |
DeprPragmaDecl SrcLoc [([Name], String)] | A DEPRECATED pragma |
WarnPragmaDecl SrcLoc [([Name], String)] | A WARNING pragma |
InlineSig SrcLoc Bool Activation QName | An INLINE pragma |
InlineConlikeSig SrcLoc Activation QName | An INLINE CONLIKE pragma |
SpecSig SrcLoc QName [Type] | A SPECIALISE pragma |
SpecInlineSig SrcLoc Bool Activation QName [Type] | A SPECIALISE INLINE pragma |
InstSig SrcLoc Context QName [Type] | A SPECIALISE instance pragma |
AnnPragma SrcLoc Annotation | An ANN pragma |
A binding group inside a let
or where
clause.
A binding of an implicit parameter.
Type classes and instances
Declarations inside a class declaration.
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 Type | strict component, marked with " |
UnBangedTy Type | non-strict component |
UnpackedTy Type | unboxed component, marked with an UNPACK pragma |
Function bindings
Clauses of a function binding.
The right hand side of a function or pattern binding.
UnGuardedRhs Exp | unguarded right hand side (exp) |
GuardedRhss [GuardedRhs] | guarded right hand side (gdrhs) |
data GuardedRhs Source
A guarded right hand side |
stmts =
exp.
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.
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 |
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 |
Flag denoting whether a tuple is boxed or unboxed.
An explicit kind annotation.
A type variable declaration, optionally with an explicit kind annotation.
KindedVar Name Kind | variable binding with kind annotation |
UnkindedVar Name | ordinary variable binding |
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 |
|
Case Exp [Alt] |
|
Do [Stmt] |
|
MDo [Stmt] |
|
Tuple [Exp] | tuple expression |
TupleSection [Maybe Exp] | tuple section expression, e.g. |
List [Exp] | list 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 |
ListComp Exp [QualStmt] | ordinary list comprehension |
ParComp Exp [[QualStmt]] | parallel list 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 |
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 |
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 Name | record field pun |
FieldWildcard | record field wildcard |
An alt alternative in a case
expression.
data GuardedAlts Source
The right-hand sides of a case
alternative,
which may be a single right-hand side or a
set of guarded ones.
UnGuardedAlt Exp |
|
GuardedAlts [GuardedAlt] | gdpat |
data GuardedAlt Source
A guarded case alternative |
stmts ->
exp.
An xml attribute, which is a name-expression pair.
Patterns
A pattern, to be matched against a value.
PVar Name | variable |
PLit Literal | literal constant |
PNeg Pat | negated pattern |
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 [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 |
PExplTypeArg QName Type | Explicit generics style type argument e.g. |
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 |
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.
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.
Builtin names
Modules
Main function of a program
Constructors
tuple_con_name :: Boxed -> Int -> QNameSource
Special identifiers
Type constructors
tuple_tycon_name :: Boxed -> Int -> QNameSource
tuple_tycon :: Boxed -> Int -> TypeSource