haskell-src-1.0.1.3: Manipulating Haskell source codeContentsIndex
Language.Haskell.Syntax
Portabilityportable
Stabilityexperimental
Maintainerlibraries@haskell.org
Contents
Modules
Declarations
Class Assertions and Contexts
Types
Expressions
Patterns
Literals
Variables, Constructors and Operators
Builtin names
Modules
Main function of a program
Constructors
Type constructors
Source coordinates
Description

A suite of datatypes describing the abstract syntax of Haskell 98 http://www.haskell.org/onlinereport/ plus a few extensions:

  • multi-parameter type classes
  • parameters of type class assertions are unrestricted

This module has been changed so that show is a real show. For GHC, we also derive Typeable and Data for all types.

Synopsis
data HsModule = HsModule SrcLoc Module (Maybe [HsExportSpec]) [HsImportDecl] [HsDecl]
data HsExportSpec
= HsEVar HsQName
| HsEAbs HsQName
| HsEThingAll HsQName
| HsEThingWith HsQName [HsCName]
| HsEModuleContents Module
data HsImportDecl = HsImportDecl {
importLoc :: SrcLoc
importModule :: Module
importQualified :: Bool
importAs :: Maybe Module
importSpecs :: Maybe (Bool, [HsImportSpec])
}
data HsImportSpec
= HsIVar HsName
| HsIAbs HsName
| HsIThingAll HsName
| HsIThingWith HsName [HsCName]
data HsAssoc
= HsAssocNone
| HsAssocLeft
| HsAssocRight
data HsDecl
= HsTypeDecl SrcLoc HsName [HsName] HsType
| HsDataDecl SrcLoc HsContext HsName [HsName] [HsConDecl] [HsQName]
| HsInfixDecl SrcLoc HsAssoc Int [HsOp]
| HsNewTypeDecl SrcLoc HsContext HsName [HsName] HsConDecl [HsQName]
| HsClassDecl SrcLoc HsContext HsName [HsName] [HsDecl]
| HsInstDecl SrcLoc HsContext HsQName [HsType] [HsDecl]
| HsDefaultDecl SrcLoc [HsType]
| HsTypeSig SrcLoc [HsName] HsQualType
| HsFunBind [HsMatch]
| HsPatBind SrcLoc HsPat HsRhs [HsDecl]
| HsForeignImport SrcLoc String HsSafety String HsName HsType
| HsForeignExport SrcLoc String String HsName HsType
data HsConDecl
= HsConDecl SrcLoc HsName [HsBangType]
| HsRecDecl SrcLoc HsName [([HsName], HsBangType)]
data HsBangType
= HsBangedTy HsType
| HsUnBangedTy HsType
data HsMatch = HsMatch SrcLoc HsName [HsPat] HsRhs [HsDecl]
data HsRhs
= HsUnGuardedRhs HsExp
| HsGuardedRhss [HsGuardedRhs]
data HsGuardedRhs = HsGuardedRhs SrcLoc HsExp HsExp
data HsSafety
= HsSafe
| HsUnsafe
data HsQualType = HsQualType HsContext HsType
type HsContext = [HsAsst]
type HsAsst = (HsQName, [HsType])
data HsType
= HsTyFun HsType HsType
| HsTyTuple [HsType]
| HsTyApp HsType HsType
| HsTyVar HsName
| HsTyCon HsQName
data HsExp
= HsVar HsQName
| HsCon HsQName
| HsLit HsLiteral
| HsInfixApp HsExp HsQOp HsExp
| HsApp HsExp HsExp
| HsNegApp HsExp
| HsLambda SrcLoc [HsPat] HsExp
| HsLet [HsDecl] HsExp
| HsIf HsExp HsExp HsExp
| HsCase HsExp [HsAlt]
| HsDo [HsStmt]
| HsTuple [HsExp]
| HsList [HsExp]
| HsParen HsExp
| HsLeftSection HsExp HsQOp
| HsRightSection HsQOp HsExp
| HsRecConstr HsQName [HsFieldUpdate]
| HsRecUpdate HsExp [HsFieldUpdate]
| HsEnumFrom HsExp
| HsEnumFromTo HsExp HsExp
| HsEnumFromThen HsExp HsExp
| HsEnumFromThenTo HsExp HsExp HsExp
| HsListComp HsExp [HsStmt]
| HsExpTypeSig SrcLoc HsExp HsQualType
| HsAsPat HsName HsExp
| HsWildCard
| HsIrrPat HsExp
data HsStmt
= HsGenerator SrcLoc HsPat HsExp
| HsQualifier HsExp
| HsLetStmt [HsDecl]
data HsFieldUpdate = HsFieldUpdate HsQName HsExp
data HsAlt = HsAlt SrcLoc HsPat HsGuardedAlts [HsDecl]
data HsGuardedAlts
= HsUnGuardedAlt HsExp
| HsGuardedAlts [HsGuardedAlt]
data HsGuardedAlt = HsGuardedAlt SrcLoc HsExp HsExp
data HsPat
= HsPVar HsName
| HsPLit HsLiteral
| HsPNeg HsPat
| HsPInfixApp HsPat HsQName HsPat
| HsPApp HsQName [HsPat]
| HsPTuple [HsPat]
| HsPList [HsPat]
| HsPParen HsPat
| HsPRec HsQName [HsPatField]
| HsPAsPat HsName HsPat
| HsPWildCard
| HsPIrrPat HsPat
data HsPatField = HsPFieldPat HsQName HsPat
data HsLiteral
= HsChar Char
| HsString String
| HsInt Integer
| HsFrac Rational
| HsCharPrim Char
| HsStringPrim String
| HsIntPrim Integer
| HsFloatPrim Rational
| HsDoublePrim Rational
newtype Module = Module String
data HsQName
= Qual Module HsName
| UnQual HsName
| Special HsSpecialCon
data HsName
= HsIdent String
| HsSymbol String
data HsQOp
= HsQVarOp HsQName
| HsQConOp HsQName
data HsOp
= HsVarOp HsName
| HsConOp HsName
data HsSpecialCon
= HsUnitCon
| HsListCon
| HsFunCon
| HsTupleCon Int
| HsCons
data HsCName
= HsVarName HsName
| HsConName HsName
main_mod :: Module
main_name :: HsName
unit_con_name :: HsQName
tuple_con_name :: Int -> HsQName
list_cons_name :: HsQName
unit_con :: HsExp
tuple_con :: Int -> HsExp
fun_tycon_name :: HsQName
tuple_tycon_name :: Int -> HsQName
fun_tycon :: HsType
tuple_tycon :: Int -> HsType
data SrcLoc = SrcLoc {
srcFilename :: String
srcLine :: Int
srcColumn :: Int
}
Modules
data HsModule
A Haskell source module.
Constructors
HsModule SrcLoc Module (Maybe [HsExportSpec]) [HsImportDecl] [HsDecl]
show/hide Instances
data HsExportSpec
Export specification.
Constructors
HsEVar HsQNamevariable
HsEAbs HsQNameT: a class or datatype exported abstractly, or a type synonym.
HsEThingAll HsQNameT(..): a class exported with all of its methods, or a datatype exported with all of its constructors.
HsEThingWith HsQName [HsCName]T(C_1,...,C_n): a class exported with some of its methods, or a datatype exported with some of its constructors.
HsEModuleContents Modulemodule M: re-export a module.
show/hide Instances
data HsImportDecl
Import declaration.
Constructors
HsImportDecl
importLoc :: SrcLocposition of the import keyword.
importModule :: Modulename of the module imported.
importQualified :: Boolimported qualified?
importAs :: Maybe Moduleoptional alias name in an as clause.
importSpecs :: Maybe (Bool, [HsImportSpec])optional list of import specifications. The Bool is True if the names are excluded by hiding.
show/hide Instances
data HsImportSpec
Import specification.
Constructors
HsIVar HsNamevariable
HsIAbs HsNameT: the name of a class, datatype or type synonym.
HsIThingAll HsNameT(..): a class imported with all of its methods, or a datatype imported with all of its constructors.
HsIThingWith HsName [HsCName]T(C_1,...,C_n): a class imported with some of its methods, or a datatype imported with some of its constructors.
show/hide Instances
data HsAssoc
Associativity of an operator.
Constructors
HsAssocNonenon-associative operator (declared with infix)
HsAssocLeftleft-associative operator (declared with infixl).
HsAssocRightright-associative operator (declared with infixr)
show/hide Instances
Declarations
data HsDecl
Constructors
HsTypeDecl SrcLoc HsName [HsName] HsType
HsDataDecl SrcLoc HsContext HsName [HsName] [HsConDecl] [HsQName]
HsInfixDecl SrcLoc HsAssoc Int [HsOp]
HsNewTypeDecl SrcLoc HsContext HsName [HsName] HsConDecl [HsQName]
HsClassDecl SrcLoc HsContext HsName [HsName] [HsDecl]
HsInstDecl SrcLoc HsContext HsQName [HsType] [HsDecl]
HsDefaultDecl SrcLoc [HsType]
HsTypeSig SrcLoc [HsName] HsQualType
HsFunBind [HsMatch]
HsPatBind SrcLoc HsPat HsRhs [HsDecl]
HsForeignImport SrcLoc String HsSafety String HsName HsType
HsForeignExport SrcLoc String String HsName HsType
show/hide Instances
data HsConDecl
Declaration of a data constructor.
Constructors
HsConDecl SrcLoc HsName [HsBangType]ordinary data constructor
HsRecDecl SrcLoc HsName [([HsName], HsBangType)]record constructor
show/hide Instances
data HsBangType
The type of a constructor argument or field, optionally including a strictness annotation.
Constructors
HsBangedTy HsTypestrict component, marked with "!"
HsUnBangedTy HsTypenon-strict component
show/hide Instances
data HsMatch
Clauses of a function binding.
Constructors
HsMatch SrcLoc HsName [HsPat] HsRhs [HsDecl]
show/hide Instances
data HsRhs
The right hand side of a function or pattern binding.
Constructors
HsUnGuardedRhs HsExpunguarded right hand side (exp)
HsGuardedRhss [HsGuardedRhs]guarded right hand side (gdrhs)
show/hide Instances
data HsGuardedRhs
A guarded right hand side | exp = exp. The first expression will be Boolean-valued.
Constructors
HsGuardedRhs SrcLoc HsExp HsExp
show/hide Instances
data HsSafety
Safety level for invoking a foreign entity
Constructors
HsSafecall may generate callbacks
HsUnsafecall will not generate callbacks
show/hide Instances
Class Assertions and Contexts
data HsQualType
A type qualified with a context. An unqualified type has an empty context.
Constructors
HsQualType HsContext HsType
show/hide Instances
type HsContext = [HsAsst]
type HsAsst = (HsQName, [HsType])
Class assertions. In Haskell 98, the argument would be a tyvar, but this definition allows multiple parameters, and allows them to be types.
Types
data HsType
Haskell types and type constructors.
Constructors
HsTyFun HsType HsTypefunction type
HsTyTuple [HsType]tuple type
HsTyApp HsType HsTypeapplication of a type constructor
HsTyVar HsNametype variable
HsTyCon HsQNamenamed type or type constructor
show/hide Instances
Expressions
data HsExp

Haskell expressions.

Notes:

  • Because it is difficult for parsers to distinguish patterns from expressions, they typically parse them in the same way and then check that they have the appropriate form. Hence the expression type includes some forms that are found only in patterns. After these checks, these constructors should not be used.
  • The parser does not take precedence and associativity into account, so it will leave HsInfixApps associated to the left.
  • The Language.Haskell.Pretty.Pretty instance for HsExp does not add parentheses in printing.
Constructors
HsVar HsQNamevariable
HsCon HsQNamedata constructor
HsLit HsLiteralliteral constant
HsInfixApp HsExp HsQOp HsExpinfix application
HsApp HsExp HsExpordinary application
HsNegApp HsExpnegation expression - exp
HsLambda SrcLoc [HsPat] HsExplambda expression
HsLet [HsDecl] HsExplocal declarations with let
HsIf HsExp HsExp HsExpif exp then exp else exp
HsCase HsExp [HsAlt]case exp of alts
HsDo [HsStmt]do-expression: the last statement in the list should be an expression.
HsTuple [HsExp]tuple expression
HsList [HsExp]list expression
HsParen HsExpparenthesized expression
HsLeftSection HsExp HsQOpleft section (exp qop)
HsRightSection HsQOp HsExpright section (qop exp)
HsRecConstr HsQName [HsFieldUpdate]record construction expression
HsRecUpdate HsExp [HsFieldUpdate]record update expression
HsEnumFrom HsExpunbounded arithmetic sequence, incrementing by 1
HsEnumFromTo HsExp HsExpbounded arithmetic sequence, incrementing by 1
HsEnumFromThen HsExp HsExpunbounded arithmetic sequence, with first two elements given
HsEnumFromThenTo HsExp HsExp HsExpbounded arithmetic sequence, with first two elements given
HsListComp HsExp [HsStmt]list comprehension
HsExpTypeSig SrcLoc HsExp HsQualTypeexpression type signature
HsAsPat HsName HsExppatterns only
HsWildCardpatterns only
HsIrrPat HsExppatterns only
show/hide Instances
data HsStmt
This type represents both stmt in a do-expression, and qual in a list comprehension.
Constructors
HsGenerator SrcLoc HsPat HsExpa generator pat <- exp
HsQualifier HsExpan exp by itself: in a do-expression, an action whose result is discarded; in a list comprehension, a guard expression
HsLetStmt [HsDecl]local bindings
show/hide Instances
data HsFieldUpdate
An fbind in a labeled record construction or update expression.
Constructors
HsFieldUpdate HsQName HsExp
show/hide Instances
data HsAlt
An alt in a case expression.
Constructors
HsAlt SrcLoc HsPat HsGuardedAlts [HsDecl]
show/hide Instances
data HsGuardedAlts
Constructors
HsUnGuardedAlt HsExp-> exp
HsGuardedAlts [HsGuardedAlt]gdpat
show/hide Instances
data HsGuardedAlt
A guarded alternative | exp -> exp. The first expression will be Boolean-valued.
Constructors
HsGuardedAlt SrcLoc HsExp HsExp
show/hide Instances
Patterns
data HsPat
A pattern, to be matched against a value.
Constructors
HsPVar HsNamevariable
HsPLit HsLiteralliteral constant
HsPNeg HsPatnegated pattern
HsPInfixApp HsPat HsQName HsPatpattern with infix data constructor
HsPApp HsQName [HsPat]data constructor and argument patterns
HsPTuple [HsPat]tuple pattern
HsPList [HsPat]list pattern
HsPParen HsPatparenthesized pattern
HsPRec HsQName [HsPatField]labelled pattern
HsPAsPat HsName HsPat@-pattern
HsPWildCardwildcard pattern (_)
HsPIrrPat HsPatirrefutable pattern (~)
show/hide Instances
data HsPatField
An fpat in a labeled record pattern.
Constructors
HsPFieldPat HsQName HsPat
show/hide Instances
Literals
data HsLiteral
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.
Constructors
HsChar Charcharacter literal
HsString Stringstring literal
HsInt Integerinteger literal
HsFrac Rationalfloating point literal
HsCharPrim CharGHC unboxed character literal
HsStringPrim StringGHC unboxed string literal
HsIntPrim IntegerGHC unboxed integer literal
HsFloatPrim RationalGHC unboxed float literal
HsDoublePrim RationalGHC unboxed double literal
show/hide Instances
Variables, Constructors and Operators
newtype Module
The name of a Haskell module.
Constructors
Module String
show/hide Instances
data HsQName
This type is used to represent qualified variables, and also qualified constructors.
Constructors
Qual Module HsNamename qualified with a module name
UnQual HsNameunqualified name
Special HsSpecialConbuilt-in constructor with special syntax
show/hide Instances
data HsName
This type is used to represent variables, and also constructors.
Constructors
HsIdent Stringvarid or conid
HsSymbol Stringvarsym or consym
show/hide Instances
data HsQOp
Possibly qualified infix operators (qop), appearing in expressions.
Constructors
HsQVarOp HsQNamevariable operator (qvarop)
HsQConOp HsQNameconstructor operator (qconop)
show/hide Instances
data HsOp
Operators, appearing in infix declarations.
Constructors
HsVarOp HsNamevariable operator (varop)
HsConOp HsNameconstructor operator (conop)
show/hide Instances
data HsSpecialCon
Constructors with special syntax. These names are never qualified, and always refer to builtin type or data constructors.
Constructors
HsUnitConunit type and data constructor ()
HsListConlist type constructor []
HsFunConfunction type constructor ->
HsTupleCon Intn-ary tuple type and data constructors (,) etc
HsConslist data constructor (:)
show/hide Instances
data HsCName
A name (cname) of a component of a class or data type in an import or export specification.
Constructors
HsVarName HsNamename of a method or field
HsConName HsNamename of a data constructor
show/hide Instances
Builtin names
Modules
main_mod :: Module
Main function of a program
main_name :: HsName
Constructors
unit_con_name :: HsQName
tuple_con_name :: Int -> HsQName
list_cons_name :: HsQName
unit_con :: HsExp
tuple_con :: Int -> HsExp
Type constructors
fun_tycon_name :: HsQName
tuple_tycon_name :: Int -> HsQName
fun_tycon :: HsType
tuple_tycon :: Int -> HsType
Source coordinates
data SrcLoc
A position in the source.
Constructors
SrcLoc
srcFilename :: String
srcLine :: Int
srcColumn :: Int
show/hide Instances
Produced by Haddock version 2.3.0