YhcSource codeContentsIndex
Syntax
Synopsis
data Module id = Module Pos id (Maybe [Export id]) [ImpDecl id] [FixDecl id] (Decls id)
data Export id
= ExportEntity Pos (Entity id)
| ExportModid Pos id
data ImpDecl id
= Import (Pos, id) (ImpSpec id)
| ImportQ (Pos, id) (ImpSpec id)
| ImportQas (Pos, id) (Pos, id) (ImpSpec id)
| Importas (Pos, id) (Pos, id) (ImpSpec id)
importedModule :: ImpDecl a -> a
data ImpSpec id
= NoHiding [Entity id]
| Hiding [Entity id]
data Entity id
= EntityVar Pos id
| EntityConClsAll Pos id
| EntityConClsSome Pos id [(Pos, id)]
data InfixClass a
= InfixDef
| InfixL
| InfixR
| Infix
| InfixPre a
type FixDecl id = (InfixClass id, Int, [FixId id])
data FixId a
= FixCon Pos a
| FixVar Pos a
stripFixId :: FixId a -> a
data Decls id
= DeclsParse [Decl id]
| DeclsScc [DeclsDepend id]
noDecls :: Decls id
data DeclsDepend id
= DeclsNoRec (Decl id)
| DeclsRec [Decl id]
data Decl id
= DeclType (Simple id) (Type id)
| DeclTypeRenamed Pos Id
| DeclData (Maybe Bool) [Context id] (Simple id) [Constr id] [(Pos, id)]
| DeclDataPrim Pos id Int
| DeclConstrs Pos id [(Pos, id, id)]
| DeclClass Pos [Context id] id [id] [FunDep id] (Decls id)
| DeclInstance Pos [Context id] id [Instance id] (Decls id)
| DeclDefault [Type id]
| DeclPrimitive Pos id Int (Type id)
| DeclForeignImp Pos CallConv String id Int Safety (Type id) id
| DeclForeignExp Pos CallConv String id (Type id)
| DeclVarsType [(Pos, id)] [Context id] (Type id)
| DeclPat (Alt id)
| DeclFun Pos id [Fun id]
| DeclIgnore String
| DeclError String
| DeclAnnot (Decl id) [Annot id]
| DeclFixity (FixDecl id)
data Safety
= Unsafe
| Safe
data CallConv
= C
| Cast
| Noproto
| Haskell
| Other String
data ClassCode ctx id
= CodeClass Pos id
| CodeInstance Pos id id [id] [ctx] [id]
data FunDep id = (:->:) [id] [id]
data Annot id
= AnnotArity (Pos, id) Int
| AnnotPrimitive (Pos, id) PackedString
| AnnotNeed [[id]]
| AnnotUnknown
data Fun id = Fun [Pat id] (Rhs id) (Decls id)
funArity :: Fun id -> Int
data Alt id = Alt (Pat id) (Rhs id) (Decls id)
data Rhs id
= Unguarded (Exp id)
| PatGuard [([Qual id], Exp id)]
data Type id
= TypeCons Pos id [Type id]
| TypeApp (Type id) (Type id)
| TypeVar Pos id
| TypeStrict Pos (Type id)
data Sig id = Sig [(Pos, id)] (Type id)
data Simple id = Simple Pos id [(Pos, id)]
simpleToType :: Simple id -> Type id
data Context id = Context Pos id [(Pos, id)]
data Constr id
= Constr Pos id [(Maybe [(Pos, id)], Type id)]
| ConstrCtx [(Pos, id)] [Context id] Pos id [(Maybe [(Pos, id)], Type id)]
getConstrId :: Constr id -> id
getConstrArgumentList :: Constr id -> [(Maybe [(Pos, id)], Type id)]
getConstrLabels :: Constr id -> [(Pos, id)]
getConstrArgumentTypes :: Constr id -> [Type id]
constrArity :: Constr id -> Int
type Instance id = Type id
data Stmt id
= StmtExp (Exp id)
| StmtBind (Exp id) (Exp id)
| StmtLet (Decls id)
type Pat id = Exp id
data Exp id
= ExpScc String (Exp id)
| ExpDict (Exp id)
| ExpLambda Pos [Pat id] (Exp id)
| ExpLet Pos (Decls id) (Exp id)
| ExpDo Pos [Stmt id]
| ExpCase Pos (Exp id) [Alt id]
| ExpFatbar (Exp id) (Exp id)
| ExpFail
| ExpIf Pos (Exp id) (Exp id) (Exp id)
| ExpType Pos (Exp id) [Context id] (Type id)
| ExpListComp Pos (Exp id) [Qual id]
| ExpListEnum Pos (Exp id) (Maybe (Exp id)) (Maybe (Exp id))
| ExpRecord (Exp id) [Field id]
| ExpApplication Pos [Exp id]
| ExpVar Pos id
| ExpCon Pos id
| ExpInfixList Pos [Exp id]
| ExpVarOp Pos id
| ExpConOp Pos id
| ExpLit Pos (Lit Boxed)
| ExpList Pos [Exp id]
| ExpBrack Pos (Exp id)
| Exp2 Pos id id
| PatAs Pos id (Pat id)
| PatWildcard Pos
| PatIrrefutable Pos (Pat id)
| PatNplusK Pos id id (Exp id) (Exp id) (Exp id)
| ExpTypeRep Pos NT
data Field id
= FieldExp Pos id (Exp id)
| FieldPun Pos id
data Boxed
= Boxed
| UnBoxed
data Lit boxed
= LitInteger boxed Integer
| LitRational boxed Rational
| LitString boxed String
| LitInt boxed Int
| LitDouble boxed Double
| LitFloat boxed Float
| LitChar boxed Char
litEqual :: Eq b => Lit b -> Lit b -> Bool
litshowsPrec :: Show b => Int -> Lit b -> ShowS
data Qual id
= QualPatExp (Pat id) (Exp id)
| QualExp (Exp id)
| QualLet (Decls id)
data Interface id = Interface Pos id [IImpDecl id] [FixDecl id] (IDecls id)
type IImpDecl id = ImpDecl id
type IDecls id = Decls id
data Pos
data TokenId
Documentation
data Module id

Note that some syntactic constructs contain the syntactic construct Type. However, the rename pass replaces this representation by the internal type representation NewType and NT. So the syntactic constructs that use Type are removed by the renaming pass or the type representation is only half translated (TokenId -> Id). Are the latter still used later?

It probably would have been better if the whole syntax had been parameterised with respect to the type representation; but such an additional parameter would also be tiresome.

Constructors
Module Pos id (Maybe [Export id]) [ImpDecl id] [FixDecl id] (Decls id)
data Export id
Constructors
ExportEntity Pos (Entity id)
ExportModid Pos id
data ImpDecl id
Constructors
Import (Pos, id) (ImpSpec id)
ImportQ (Pos, id) (ImpSpec id)
ImportQas (Pos, id) (Pos, id) (ImpSpec id)
Importas (Pos, id) (Pos, id) (ImpSpec id)
importedModule :: ImpDecl a -> a
data ImpSpec id
Constructors
NoHiding [Entity id]
Hiding [Entity id]
data Entity id
Constructors
EntityVar Pos id
varid
EntityConClsAll Pos id
TyCon(..) | TyCls(..)
EntityConClsSome Pos id [(Pos, id)]
TyCon | TyCls | TyCon(conid,..,conid) | TyCls(varid,..,varid)
show/hide Instances
data InfixClass a
Constructors
InfixDef
InfixL
InfixR
Infix
InfixPre a
show/hide Instances
Eq (InfixClass a)
Show a => Show (InfixClass a)
type FixDecl id = (InfixClass id, Int, [FixId id])
data FixId a
Constructors
FixCon Pos a
FixVar Pos a
show/hide Instances
stripFixId :: FixId a -> a
data Decls id
Constructors
DeclsParse [Decl id]
DeclsScc [DeclsDepend id]
show/hide Instances
noDecls :: Decls id
data DeclsDepend id
Constructors
DeclsNoRec (Decl id)
DeclsRec [Decl id]
show/hide Instances
data Decl id
Constructors
DeclType (Simple id) (Type id)for type synonym: type simple = type
DeclTypeRenamed Pos Idrenamer replaces DeclType by this. the type is in the symbol table, referenced by Id
DeclData (Maybe Bool) [Context id] (Simple id) [Constr id] [(Pos, id)]{Nothing = newtype, Just False = data, Just True = data unboxed} context => simple = constrs deriving (tycls)
DeclDataPrim Pos id Intdata primitive conid size
DeclConstrs Pos id [(Pos, id, id)]Introduced by Rename to mark that we might need to generate selector functions position data/dataprim [(field,selector)]
DeclClass Pos [Context id] id [id] [FunDep id] (Decls id)class context => class where { signatures/valdefs; } position, context, class, type variables, fundeps, method decls
DeclInstance Pos [Context id] id [Instance id] (Decls id)instance context => tycls inst where { valdefs }
DeclDefault [Type id]default (type,..)
DeclPrimitive Pos id Int (Type id)var primitive arity :: type
DeclForeignImp Pos CallConv String id Int Safety (Type id) idforeign import [callconv] [extfun] [unsafe|cast|noproto] var :: type (final id part is wrapper-fn for IO) callconv extfun intfun arity [u|c|n] ty wrapperId
DeclForeignExp Pos CallConv String id (Type id)foreign export callconv [extfun] var :: type
DeclVarsType [(Pos, id)] [Context id] (Type id)vars :: context => type
DeclPat (Alt id)
DeclFun Pos id [Fun id]introduced with pattern elimination (id = select Int id) Used for unimplemented things
DeclIgnore String
DeclError String
DeclAnnot (Decl id) [Annot id]
DeclFixity (FixDecl id)infix[rl] int id,..,id
show/hide Instances
data Safety
for foreign imports/exports
Constructors
Unsafe
Safe
show/hide Instances
Show Safety
data CallConv
supported foreign calling conventions
Constructors
C
Cast
Noproto
Haskell
Other String
show/hide Instances
data ClassCode ctx id
introduced by RmClasses
Constructors
CodeClass Pos idclass id
CodeInstance Pos id id [id] [ctx] [id]
data FunDep id
We parse MPTC with functional dependencies, only for hat-trans.
Constructors
(:->:) [id] [id]
data Annot id
Constructors
AnnotArity (Pos, id) Int
AnnotPrimitive (Pos, id) PackedString
AnnotNeed [[id]]
AnnotUnknown
data Fun id
lhs pats, guarded exprs, local defs
Constructors
Fun [Pat id] (Rhs id) (Decls id)
show/hide Instances
funArity :: Fun id -> Int
data Alt id
Constructors
Alt (Pat id) (Rhs id) (Decls id)
show/hide Instances
data Rhs id
Constructors
Unguarded (Exp id)
PatGuard [([Qual id], Exp id)]the list has at least one element
show/hide Instances
data Type id
Constructors
TypeCons Pos id [Type id]
TypeApp (Type id) (Type id)
TypeVar Pos id
TypeStrict Pos (Type id)
show/hide Instances
data Sig id
Constructors
Sig [(Pos, id)] (Type id)
data Simple id
Constructors
Simple Pos id [(Pos, id)]
show/hide Instances
simpleToType :: Simple id -> Type id
data Context id
Constructors
Context Pos id [(Pos, id)]
show/hide Instances
data Constr id

Data constructor applied to type variables, possibly with field names. As appearing on right hand side of data or newtype definition.

  • ConstrCtx is always used if forall is specified
  • the intention is to remove Constr completely when all of nhc13 have been updated
  • this isn't nhc13, but rather Yhc
  • we have comments on the fields here, but can't make them docstrings without record syntax
Constructors
Constr Pos id [(Maybe [(Pos, id)], Type id)]
ConstrCtx [(Pos, id)] [Context id] Pos id [(Maybe [(Pos, id)], Type id)]
show/hide Instances
getConstrId :: Constr id -> id
getConstrArgumentList :: Constr id -> [(Maybe [(Pos, id)], Type id)]
getConstrLabels :: Constr id -> [(Pos, id)]
getConstrArgumentTypes :: Constr id -> [Type id]
constrArity :: Constr id -> Int
type Instance id
 = Type idNot TypeVar
data Stmt id
The following is ismorphic to the type constructor Qual. Possibly Stmt should be removed and its usage replaced everywhere by Qual.
Constructors
StmtExp (Exp id)
exp
StmtBind (Exp id) (Exp id)
pat <- exp
StmtLet (Decls id)
let { decls ; }
show/hide Instances
type Pat id = Exp id
data Exp id
used both for expressions and patterns
Constructors
ExpScc String (Exp id)never used! should probably be removed
ExpDict (Exp id)hack to mark dictionary arguments
ExpLambda Pos [Pat id] (Exp id)
 pat ... pat -> exp
ExpLet Pos (Decls id) (Exp id)
let { decls ; } in exp
ExpDo Pos [Stmt id]
do { stmts ; }
ExpCase Pos (Exp id) [Alt id]
case exp of { alts; }
ExpFatbar (Exp id) (Exp id)never used! should probably be removed
ExpFailnever used! should probably be removed
ExpIf Pos (Exp id) (Exp id) (Exp id)
if exp then exp else exp
ExpType Pos (Exp id) [Context id] (Type id)exp :: context => type next two are sugared lists; introduced for hpc-trans
ExpListComp Pos (Exp id) [Qual id]
ExpListEnum Pos (Exp id) (Maybe (Exp id)) (Maybe (Exp id))
ExpRecord (Exp id) [Field id]
ExpApplication Pos [Exp id]
ExpVar Pos id
ExpCon Pos id
ExpInfixList Pos [Exp id]
ExpVarOp Pos id
ExpConOp Pos id
ExpLit Pos (Lit Boxed)
ExpList Pos [Exp id]
ExpBrack Pos (Exp id)
Exp2 Pos id ide.g. Ord.Eq or Eq.Int
PatAs Pos id (Pat id)
PatWildcard Pos
PatIrrefutable Pos (Pat id)
PatNplusK Pos id id (Exp id) (Exp id) (Exp id)
ExpTypeRep Pos NTtypeRep introduced by the type check selection
show/hide Instances
data Field id
Constructors
FieldExp Pos id (Exp id)
FieldPun Pos idH98 removes (retained for error msgs)
show/hide Instances
data Boxed
Constructors
Boxed
UnBoxed
show/hide Instances
Eq Boxed
Show Boxed
data Lit boxed
Constructors
LitInteger boxed Integer
LitRational boxed Rational
LitString boxed String
LitInt boxed Int
LitDouble boxed Double
LitFloat boxed Float
LitChar boxed Char
show/hide Instances
Eq b => Eq (Lit b)
Show b => Show (Lit b)
litEqual :: Eq b => Lit b -> Lit b -> Bool
litshowsPrec :: Show b => Int -> Lit b -> ShowS
data Qual id
Constructors
QualPatExp (Pat id) (Exp id)
QualExp (Exp id)
QualLet (Decls id)
show/hide Instances
data Interface id
Constructors
Interface Pos id [IImpDecl id] [FixDecl id] (IDecls id)
type IImpDecl id = ImpDecl id
type IDecls id = Decls id
data Pos
abstract type for storing the position of a syntactic construct in a file, that is, line and column number of both start and end positions.
show/hide Instances
Eq Pos
Ord Pos
Show Pos
data TokenId
show/hide Instances
Produced by Haddock version 0.8