Haskell Hierarchical Libraries (haskell-src package)ContentsIndex
Language.Haskell.Syntax
Portability portable
Stability experimental
Maintainer libraries@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
Special identifiers
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.

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 SrcLoc Module Bool (Maybe Module) (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]
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 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
= HsInt Integer
| HsChar Char
| HsString String
| 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
prelude_mod :: Module
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
as_name :: HsName
qualified_name :: HsName
hiding_name :: HsName
minus_name :: HsName
pling_name :: HsName
unit_tycon_name :: HsQName
fun_tycon_name :: HsQName
list_tycon_name :: HsQName
tuple_tycon_name :: Int -> HsQName
unit_tycon :: HsType
fun_tycon :: HsType
list_tycon :: HsType
tuple_tycon :: Int -> HsType
data SrcLoc = SrcLoc {
srcFilename :: String
srcLine :: Int
srcColumn :: Int
}
Modules
data HsModule
Constructors
HsModule SrcLoc Module (Maybe [HsExportSpec]) [HsImportDecl] [HsDecl]
Instances
Pretty HsModule
Show HsModule
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.
Instances
Pretty HsExportSpec
Eq HsExportSpec
Show HsExportSpec
data HsImportDecl
Import declaration.
Constructors
HsImportDecl SrcLoc Module Bool (Maybe Module) (Maybe (Bool, [HsImportSpec]))
Instances
Pretty HsImportDecl
Eq HsImportDecl
Show HsImportDecl
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.
Instances
Pretty HsImportSpec
Eq HsImportSpec
Show HsImportSpec
data HsAssoc
Constructors
HsAssocNone
HsAssocLeft
HsAssocRight
Instances
Pretty HsAssoc
Eq HsAssoc
Show HsAssoc
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]
Instances
Pretty HsDecl
Eq HsDecl
Show HsDecl
data HsConDecl
Constructors
HsConDecl SrcLoc HsName [HsBangType]
HsRecDecl SrcLoc HsName [([HsName], HsBangType)]
Instances
Pretty HsConDecl
Eq HsConDecl
Show HsConDecl
data HsBangType
Constructors
HsBangedTy HsType
HsUnBangedTy HsType
Instances
Pretty HsBangType
Eq HsBangType
Show HsBangType
data HsMatch
Constructors
HsMatch SrcLoc HsName [HsPat] HsRhs [HsDecl]
Instances
Pretty HsMatch
Eq HsMatch
Show HsMatch
data HsRhs
Constructors
HsUnGuardedRhs HsExp
HsGuardedRhss [HsGuardedRhs]
Instances
Pretty HsRhs
Eq HsRhs
Show HsRhs
data HsGuardedRhs
Constructors
HsGuardedRhs SrcLoc HsExp HsExp
Instances
Pretty HsGuardedRhs
Eq HsGuardedRhs
Show HsGuardedRhs
Class Assertions and Contexts
data HsQualType
A type qualified with a context. An unqualified type has an empty context.
Constructors
HsQualType HsContext HsType
Instances
Pretty HsQualType
Eq HsQualType
Show HsQualType
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
Constructors
HsTyFun HsType HsType
HsTyTuple [HsType]
HsTyApp HsType HsType
HsTyVar HsName
HsTyCon HsQName
Instances
Pretty HsType
Eq HsType
Show HsType
Expressions
data HsExp
Haskell expressions. 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.
Constructors
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]Do expression: The last statement in the list should be an expression.
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 HsExppatterns only
HsWildCardpatterns only
HsIrrPat HsExppatterns only
Instances
Pretty HsExp
Eq HsExp
Show HsExp
data HsStmt
This type represents both stmt in a do-expression, and qual in a list comprehension.
Constructors
HsGenerator SrcLoc HsPat HsExp
HsQualifier HsExp
HsLetStmt [HsDecl]
Instances
Pretty HsStmt
Eq HsStmt
Show HsStmt
data HsFieldUpdate
An fbind in a labeled construction or update.
Constructors
HsFieldUpdate HsQName HsExp
Instances
Pretty HsFieldUpdate
Eq HsFieldUpdate
Show HsFieldUpdate
data HsAlt
Constructors
HsAlt SrcLoc HsPat HsGuardedAlts [HsDecl]
Instances
Pretty HsAlt
Eq HsAlt
Show HsAlt
data HsGuardedAlts
Constructors
HsUnGuardedAlt HsExp
HsGuardedAlts [HsGuardedAlt]
Instances
Pretty HsGuardedAlts
Eq HsGuardedAlts
Show HsGuardedAlts
data HsGuardedAlt
Constructors
HsGuardedAlt SrcLoc HsExp HsExp
Instances
Pretty HsGuardedAlt
Eq HsGuardedAlt
Show HsGuardedAlt
Patterns
data HsPat
Constructors
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
Instances
Pretty HsPat
Eq HsPat
Show HsPat
data HsPatField
Constructors
HsPFieldPat HsQName HsPat
Instances
Pretty HsPatField
Eq HsPatField
Show HsPatField
Literals
data HsLiteral
literal
Constructors
HsInt Integer
HsChar Char
HsString String
HsFrac Rational
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
Instances
Pretty HsLiteral
Eq HsLiteral
Show HsLiteral
Variables, Constructors and Operators
newtype Module
Constructors
Module String
Instances
Pretty Module
Eq Module
Ord Module
Show Module
data HsQName
This type is used to represent qualified variables, and also qualified constructors.
Constructors
Qual Module HsName
UnQual HsName
Special HsSpecialCon
Instances
Pretty HsQName
Eq HsQName
Ord HsQName
Show HsQName
data HsName
This type is used to represent variables, and also constructors.
Constructors
HsIdent Stringvarid or conid.
HsSymbol Stringvarsym or consym
Instances
Pretty HsName
Eq HsName
Ord HsName
Show HsName
data HsQOp
Possibly qualified infix operators (qop), appearing in expressions.
Constructors
HsQVarOp HsQName
HsQConOp HsQName
Instances
Pretty HsQOp
Eq HsQOp
Ord HsQOp
Show HsQOp
data HsOp
Operators, appearing in infix declarations.
Constructors
HsVarOp HsName
HsConOp HsName
Instances
Pretty HsOp
Eq HsOp
Ord HsOp
Show HsOp
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 (:)
Instances
Eq HsSpecialCon
Ord HsSpecialCon
Show HsSpecialCon
data HsCName
Constructors
HsVarName HsName
HsConName HsName
Instances
Pretty HsCName
Eq HsCName
Ord HsCName
Show HsCName
Builtin names
Modules
prelude_mod :: Module
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
Special identifiers
as_name :: HsName
qualified_name :: HsName
hiding_name :: HsName
minus_name :: HsName
pling_name :: HsName
Type constructors
unit_tycon_name :: HsQName
fun_tycon_name :: HsQName
list_tycon_name :: HsQName
tuple_tycon_name :: Int -> HsQName
unit_tycon :: HsType
fun_tycon :: HsType
list_tycon :: HsType
tuple_tycon :: Int -> HsType
Source coordinates
data SrcLoc
A position in the source.
Constructors
SrcLoc
srcFilename :: String
srcLine :: Int
srcColumn :: Int
Instances
Eq SrcLoc
Ord SrcLoc
Show SrcLoc
Produced by Haddock version 0.6