ghc-7.6.3: The GHC API

Safe HaskellNone

HsExpr

Contents

Description

Abstract Haskell syntax for expressions.

Synopsis

Expressions proper

type LHsExpr id = Located (HsExpr id)

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 SyntaxTable id = [(Name, SyntaxExpr id)]

Currently used only for CmdTop (sigh)

  • Before the renamer, this list is noSyntaxTable
  • After the renamer, it takes the form [(std_name, HsVar actual_name)] For example, for the return op of a monad
  • normal case: (GHC.Base.return, HsVar GHC.Base.return)
  • with rebindable syntax: (GHC.Base.return, return_22) where return_22 is whatever return is in scope
  • After the type checker, it takes the form [(std_name, expression)] where expression is the evidence for the method

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) 
HsLamCase PostTcType (MatchGroup id) 
HsApp (LHsExpr id) (LHsExpr id) 
OpApp (LHsExpr id) (LHsExpr id) Fixity (LHsExpr id) 
NegApp (LHsExpr id) (SyntaxExpr id) 
HsPar (LHsExpr id) 
SectionL (LHsExpr id) (LHsExpr id) 
SectionR (LHsExpr id) (LHsExpr id) 
ExplicitTuple [HsTupArg id] Boxity 
HsCase (LHsExpr id) (MatchGroup id) 
HsIf (Maybe (SyntaxExpr id)) (LHsExpr id) (LHsExpr id) (LHsExpr id) 
HsMultiIf PostTcType [LGRHS id] 
HsLet (HsLocalBinds id) (LHsExpr id) 
HsDo (HsStmtContext Name) [LStmt id] PostTcType 
ExplicitList PostTcType [LHsExpr id] 
ExplicitPArr PostTcType [LHsExpr id] 
RecordCon (Located id) PostTcExpr (HsRecordBinds id) 
RecordUpd (LHsExpr id) (HsRecordBinds id) [DataCon] [PostTcType] [PostTcType] 
ExprWithTySig (LHsExpr id) (LHsType id) 
ExprWithTySigOut (LHsExpr id) (LHsType Name) 
ArithSeq PostTcExpr (ArithSeqInfo id) 
PArrSeq PostTcExpr (ArithSeqInfo id) 
HsSCC FastString (LHsExpr id) 
HsCoreAnn FastString (LHsExpr id) 
HsBracket (HsBracket id) 
HsBracketOut (HsBracket Name) [PendingSplice] 
HsSpliceE (HsSplice id) 
HsQuasiQuoteE (HsQuasiQuote id) 
HsProc (LPat id) (LHsCmdTop id) 
HsArrApp (LHsExpr id) (LHsExpr id) PostTcType HsArrAppType Bool 
HsArrForm (LHsExpr id) (Maybe Fixity) [LHsCmdTop id] 
HsTick (Tickish id) (LHsExpr id) 
HsBinTick Int Int (LHsExpr id) 
HsTickPragma (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) 

Instances

data HsTupArg id

Constructors

Present (LHsExpr id) 
Missing PostTcType 

Instances

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

type HsCmd id = HsExpr id

type LHsCmd id = LHsExpr id

type LHsCmdTop id = Located (HsCmdTop id)

data HsCmdTop id

Constructors

HsCmdTop (LHsCmd id) [PostTcType] PostTcType (SyntaxTable id) 

data MatchGroup id

Constructors

MatchGroup [LMatch id] PostTcType 

Instances

type LMatch id = Located (Match id)

data Match id

Constructors

Match [LPat id] (Maybe (LHsType id)) (GRHSs id) 

Instances

Typeable1 Match 
Data id => Data (Match id) 

hsLMatchPats :: LMatch id -> [LPat id]

data GRHSs id

GRHSs are used both for pattern bindings and for Matches

Constructors

GRHSs 

Fields

grhssGRHSs :: [LGRHS id]

Guarded RHSs

grhssLocalBinds :: HsLocalBinds id

The where clause

Instances

Typeable1 GRHSs 
Data id => Data (GRHSs id) 

type LGRHS id = Located (GRHS id)

data GRHS id

Guarded Right Hand Side.

Constructors

GRHS [LStmt id] (LHsExpr id) 

Instances

Typeable1 GRHS 
Data id => Data (GRHS id) 

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

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

type LStmt id = Located (StmtLR id id)

type LStmtLR idL idR = Located (StmtLR idL idR)

type Stmt id = StmtLR id id

data StmtLR idL idR

Instances

Typeable2 StmtLR 
(Data idL, Data idR) => Data (StmtLR idL idR) 
(OutputableBndr idL, OutputableBndr idR) => Outputable (StmtLR idL idR) 

data ParStmtBlock idL idR

Constructors

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

Instances

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

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

pprDo :: OutputableBndr id => HsStmtContext any -> [LStmt id] -> SDoc

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

pprComp :: OutputableBndr id => [LStmt id] -> SDoc

data HsSplice id

Constructors

HsSplice id (LHsExpr id) 

data HsBracket id

Constructors

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

data ArithSeqInfo id

Constructors

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