ghc-7.10.2: The GHC API

Safe HaskellNone
LanguageHaskell2010

HsExpr

Contents

Description

Abstract Haskell syntax for expressions.

Synopsis

Expressions proper

type LHsExpr id

Arguments

 = Located (HsExpr id)

May have AnnKeywordId : AnnComma when in a list

type PostTcExpr = HsExpr Id

PostTcExpr is an evidence expression attached to the syntax tree by the type checker (c.f. postTcType).

type PostTcTable = [(Name, PostTcExpr)]

We use a PostTcTable where there are a bunch of pieces of evidence, more than is convenient to keep individually.

type SyntaxExpr id = HsExpr id

SyntaxExpr is like PostTcExpr, but it's filled in a little earlier, by the renamer. It's used for rebindable syntax.

E.g. (>>=) is filled in before the renamer by the appropriate Name for (>>=), and then instantiated by the type checker with its type args etc

type CmdSyntaxTable id = [(Name, SyntaxExpr id)]

data HsExpr id

A Haskell expression.

Constructors

HsVar id

Variable

HsIPVar HsIPName

Implicit parameter

HsOverLit (HsOverLit id)

Overloaded literals

HsLit HsLit

Simple (non-overloaded) literals

HsLam (MatchGroup id (LHsExpr id))

Lambda abstraction. Currently always a single match

HsLamCase (PostTc id Type) (MatchGroup id (LHsExpr id))

Lambda-case

HsApp (LHsExpr id) (LHsExpr id)

Application

OpApp (LHsExpr id) (LHsExpr id) (PostRn id Fixity) (LHsExpr id)

Operator applications: NB Bracketed ops such as (+) come out as Vars.

NegApp (LHsExpr id) (SyntaxExpr id)

Negation operator. Contains the negated expression and the name of negate

HsPar (LHsExpr id)

Parenthesised expr; see Note [Parens in HsSyn]

SectionL (LHsExpr id) (LHsExpr id) 
SectionR (LHsExpr id) (LHsExpr id) 
ExplicitTuple [LHsTupArg id] Boxity

Used for explicit tuples and sections thereof

HsCase (LHsExpr id) (MatchGroup id (LHsExpr id))
HsIf (Maybe (SyntaxExpr id)) (LHsExpr id) (LHsExpr id) (LHsExpr id)
HsMultiIf (PostTc id Type) [LGRHS id (LHsExpr id)]

Multi-way if

HsLet (HsLocalBinds id) (LHsExpr id)

let(rec)

HsDo (HsStmtContext Name) [ExprLStmt id] (PostTc id Type)
ExplicitList (PostTc id Type) (Maybe (SyntaxExpr id)) [LHsExpr id]

Syntactic list: [a,b,c,...]

ExplicitPArr (PostTc id Type) [LHsExpr id]

Syntactic parallel array: [:e1, ..., en:]

RecordCon (Located id) PostTcExpr (HsRecordBinds id)

Record construction

RecordUpd (LHsExpr id) (HsRecordBinds id) [DataCon] [PostTc id Type] [PostTc id Type]

Record update

ExprWithTySig (LHsExpr id) (LHsType id) (PostRn id [Name])

Expression with an explicit type signature. e :: type

ExprWithTySigOut (LHsExpr id) (LHsType Name) 
ArithSeq PostTcExpr (Maybe (SyntaxExpr id)) (ArithSeqInfo id)

Arithmetic sequence

PArrSeq PostTcExpr (ArithSeqInfo id)

Arithmetic sequence for parallel array

[:e1..e2:] or [:e1, e2..e3:]
HsSCC SourceText FastString (LHsExpr id)
HsCoreAnn SourceText FastString (LHsExpr id)
HsBracket (HsBracket id)
HsRnBracketOut (HsBracket Name) [PendingRnSplice] 
HsTcBracketOut (HsBracket Name) [PendingTcSplice] 
HsSpliceE Bool (HsSplice id)
HsQuasiQuoteE (HsQuasiQuote id) 
HsProc (LPat id) (LHsCmdTop id)

proc notation for Arrows

HsStatic (LHsExpr id)
HsArrApp (LHsExpr id) (LHsExpr id) (PostTc id Type) HsArrAppType Bool
HsArrForm (LHsExpr id) (Maybe Fixity) [LHsCmdTop id]
HsTick (Tickish id) (LHsExpr id) 
HsBinTick Int Int (LHsExpr id) 
HsTickPragma SourceText (FastString, (Int, Int), (Int, Int)) (LHsExpr id)
EWildPat 
EAsPat (Located id) (LHsExpr id)
EViewPat (LHsExpr id) (LHsExpr id)
ELazyPat (LHsExpr id)
HsType (LHsType id) 
HsWrap HsWrapper (HsExpr id) 
HsUnboundVar RdrName 

Instances

type LHsTupArg id = Located (HsTupArg id)

HsTupArg is used for tuple sections (,a,) is represented by ExplicitTuple [Missing ty1, Present a, Missing ty3] Which in turn stands for (x:ty1 y:ty2. (x,a,y))

data HsTupArg id

Constructors

Present (LHsExpr id)

The argument

Missing (PostTc id Type)

The argument is missing, but this is its type

Instances

DataId id => Data (HsTupArg id) 

ppr_expr :: forall id. OutputableBndr id => HsExpr id -> SDoc

type LHsCmd id = Located (HsCmd id)

type LHsCmdTop id = Located (HsCmdTop id)

Top-level command, introducing a new arrow. This may occur inside a proc (where the stack is empty) or as an argument of a command-forming operator.

data HsCmdTop id

Constructors

HsCmdTop (LHsCmd id) (PostTc id Type) (PostTc id Type) (CmdSyntaxTable id) 

Instances

ppr_cmd :: forall id. OutputableBndr id => HsCmd id -> SDoc

data MatchGroup id body

Constructors

MG 

Fields

mg_alts :: [LMatch id body]
 
mg_arg_tys :: [PostTc id Type]
 
mg_res_ty :: PostTc id Type
 
mg_origin :: Origin
 

Instances

(Data body, DataId id) => Data (MatchGroup id body) 

type LMatch id body = Located (Match id body)

May have AnnKeywordId : AnnSemi when in a list

data Match id body

Constructors

Match 

Fields

m_fun_id_infix :: Maybe (Located id, Bool)
 
m_pats :: [LPat id]
 
m_type :: Maybe (LHsType id)
 
m_grhss :: GRHSs id body
 

Instances

(Data body, DataId id) => Data (Match id body) 

hsLMatchPats :: LMatch id body -> [LPat id]

data GRHSs id body

GRHSs are used both for pattern bindings and for Matches

Constructors

GRHSs 

Fields

grhssGRHSs :: [LGRHS id body]

Guarded RHSs

grhssLocalBinds :: HsLocalBinds id

The where clause

Instances

(Data body, DataId id) => Data (GRHSs id body) 

type LGRHS id body = Located (GRHS id body)

data GRHS id body

Guarded Right Hand Side.

Constructors

GRHS [GuardLStmt id] body 

Instances

(Data body, DataId id) => Data (GRHS id body) 

pprFunBind :: (OutputableBndr idL, OutputableBndr idR, Outputable body) => idL -> Bool -> MatchGroup idR body -> SDoc

pprPatBind :: forall bndr id body. (OutputableBndr bndr, OutputableBndr id, Outputable body) => LPat bndr -> GRHSs id body -> SDoc

pprMatch :: (OutputableBndr idL, OutputableBndr idR, Outputable body) => HsMatchContext idL -> Match idR body -> SDoc

pprGRHSs :: (OutputableBndr idL, OutputableBndr idR, Outputable body) => HsMatchContext idL -> GRHSs idR body -> SDoc

pprGRHS :: (OutputableBndr idL, OutputableBndr idR, Outputable body) => HsMatchContext idL -> GRHS idR body -> SDoc

pp_rhs :: Outputable body => HsMatchContext idL -> body -> SDoc

type LStmt id body = Located (StmtLR id id body)

type LStmtLR idL idR body = Located (StmtLR idL idR body)

type Stmt id body = StmtLR id id body

type CmdLStmt id = LStmt id (LHsCmd id)

type CmdStmt id = Stmt id (LHsCmd id)

type ExprLStmt id = LStmt id (LHsExpr id)

type ExprStmt id = Stmt id (LHsExpr id)

type GuardLStmt id = LStmt id (LHsExpr id)

type GuardStmt id = Stmt id (LHsExpr id)

type GhciLStmt id = LStmt id (LHsExpr id)

type GhciStmt id = Stmt id (LHsExpr id)

data StmtLR idL idR body

API Annotations when in qualifier lists or guards - AnnKeywordId : AnnVbar, AnnComma,AnnThen, AnnBy,AnnBy, AnnGroup,AnnUsing

Instances

(Data body, DataId idL, DataId idR) => Data (StmtLR idL idR body) 
(OutputableBndr idL, OutputableBndr idR, Outputable body) => Outputable (StmtLR idL idR body) 

data TransForm

Constructors

ThenForm 
GroupForm 

Instances

data ParStmtBlock idL idR

Constructors

ParStmtBlock [ExprLStmt idL] [idR] (SyntaxExpr idR) 

Instances

(DataId idL, DataId idR) => Data (ParStmtBlock idL idR) 
(OutputableBndr idL, OutputableBndr idR) => Outputable (ParStmtBlock idL idR) 

pprStmt :: (OutputableBndr idL, OutputableBndr idR, Outputable body) => StmtLR idL idR body -> SDoc

pprTransformStmt :: OutputableBndr id => [id] -> LHsExpr id -> Maybe (LHsExpr id) -> SDoc

pprTransStmt :: Outputable body => Maybe body -> body -> TransForm -> SDoc

pprBy :: Outputable body => Maybe body -> SDoc

pprDo :: (OutputableBndr id, Outputable body) => HsStmtContext any -> [LStmt id body] -> SDoc

ppr_do_stmts :: (OutputableBndr idL, OutputableBndr idR, Outputable body) => [LStmtLR idL idR body] -> SDoc

pprComp :: (OutputableBndr id, Outputable body) => [LStmt id body] -> SDoc

pprQuals :: (OutputableBndr id, Outputable body) => [LStmt id body] -> SDoc

data HsSplice id

Constructors

HsSplice id (LHsExpr id) 

Instances

data PendingSplice id

Constructors

PendSplice Name (LHsExpr id) 

data HsBracket id

Constructors

ExpBr (LHsExpr id) 
PatBr (LPat id) 
DecBrL [LHsDecl id] 
DecBrG (HsGroup id) 
TypBr (LHsType id) 
VarBr Bool id 
TExpBr (LHsExpr id) 

Instances

data ArithSeqInfo id

Constructors

From (LHsExpr id) 
FromThen (LHsExpr id) (LHsExpr id) 
FromTo (LHsExpr id) (LHsExpr id) 
FromThenTo (LHsExpr id) (LHsExpr id) (LHsExpr id) 

Instances

pprStmtInCtxt :: (OutputableBndr idL, OutputableBndr idR, Outputable body) => HsStmtContext idL -> StmtLR idL idR body -> SDoc