| OpApp (HsExpr id) -- left operand
(HsExpr id) -- operator
- Fixity -- Renamer adds fixity; bottom until then
+ Fixity -- Renamer adds fixity; bottom until then
(HsExpr id) -- right operand
-- We preserve prefix negation and parenthesis for the precedence parser.
| HsLet (HsBinds id) -- let(rec)
(HsExpr id)
- | HsWith (HsExpr id) -- implicit parameter binding
- [(IPName id, HsExpr id)]
- Bool -- True <=> this was a 'with' binding
- -- (tmp, until 'with' is removed)
-
| HsDo (HsStmtContext Name) -- The parameterisation is unimportant
-- because in this context we never use
- -- the FunRhs variant
+ -- the PatGuard or ParStmt variant
[Stmt id] -- "do":one or more stmts
[id] -- Ids for [return,fail,>>=,>>]
-- Brutal but simple
| HsSCC FastString -- "set cost centre" (_scc_) annotation
(HsExpr id) -- expr whose cost is to be measured
+
+ | HsCoreAnn FastString -- hdaume: core annotation
+ (HsExpr id)
-- MetaHaskell Extensions
| HsBracket (HsBracket id) SrcLoc
| HsSplice id (HsExpr id) SrcLoc -- $z or $(f 4)
-- The id is just a unique name to
-- identify this splice point
+
+ | HsReify (HsReify id) -- reifyType t, reifyDecl i, reifyFixity
\end{code}
= sep [hang (ptext SLIT("let")) 2 (pprBinds binds),
hang (ptext SLIT("in")) 2 (ppr expr)]
-ppr_expr (HsWith expr binds is_with)
- = sep [hang (ptext SLIT("let")) 2 (pp_ipbinds binds),
- hang (ptext SLIT("in")) 2 (ppr expr)]
-
ppr_expr (HsDo do_or_list_comp stmts _ _ _) = pprDo do_or_list_comp stmts
ppr_expr (ExplicitList _ exprs)
ppr_expr (HsSplice n e _) = char '$' <> brackets (ppr n) <> pprParendExpr e
ppr_expr (HsBracket b _) = pprHsBracket b
ppr_expr (HsBracketOut e ps) = ppr e $$ ptext SLIT("where") <+> ppr ps
+ppr_expr (HsReify r) = ppr r
-- add parallel array brackets around a document
--
pp_rbind (v, e) = hsep [pprBndr LetBind v, char '=', ppr e]
\end{code}
-\begin{code}
-pp_ipbinds :: OutputableBndr id => [(IPName id, HsExpr id)] -> SDoc
-pp_ipbinds pairs = hsep (punctuate semi (map pp_item pairs))
- where
- pp_item (id,rhs) = pprBndr LetBind id <+> equals <+> ppr_expr rhs
-\end{code}
%************************************************************************
thBrackets pp_kind pp_body = char '[' <> pp_kind <> char '|' <+>
pp_body <+> ptext SLIT("|]")
+
+data HsReify id = Reify ReifyFlavour id -- Pre typechecking
+ | ReifyOut ReifyFlavour Name -- Post typechecking
+ -- The Name could be the name of
+ -- an Id, TyCon, or Class
+
+data ReifyFlavour = ReifyDecl | ReifyType | ReifyFixity
+
+instance Outputable id => Outputable (HsReify id) where
+ ppr (Reify flavour id) = ppr flavour <+> ppr id
+ ppr (ReifyOut flavour thing) = ppr flavour <+> ppr thing
+
+instance Outputable ReifyFlavour where
+ ppr ReifyDecl = ptext SLIT("reifyDecl")
+ ppr ReifyType = ptext SLIT("reifyType")
+ ppr ReifyFixity = ptext SLIT("reifyFixity")
\end{code}
%************************************************************************
| MDoExpr -- Recursive do-expression
| PArrComp -- Parallel array comprehension
| PatGuard (HsMatchContext id) -- Pattern guard for specified thing
+ | ParStmtCtxt (HsStmtContext id) -- A branch of a parallel stmt
\end{code}
\begin{code}
pprMatchRhsContext LambdaExpr = ptext SLIT("the body of a lambda")
pprMatchRhsContext RecUpd = panic "pprMatchRhsContext"
+pprStmtContext (ParStmtCtxt c) = sep [ptext SLIT("a parallel branch of"), pprStmtContext c]
pprStmtContext (PatGuard ctxt) = ptext SLIT("a pattern guard for") $$ pprMatchContext ctxt
pprStmtContext DoExpr = ptext SLIT("a 'do' expression")
pprStmtContext MDoExpr = ptext SLIT("an 'mdo' expression")
-- Used to generate the string for a *runtime* error message
-matchContextErrString (FunRhs fun) = "function " ++ showSDoc (ppr fun)
-matchContextErrString CaseAlt = "case"
-matchContextErrString PatBindRhs = "pattern binding"
-matchContextErrString RecUpd = "record update"
-matchContextErrString LambdaExpr = "lambda"
-matchContextErrString (StmtCtxt (PatGuard _)) = "pattern gaurd"
-matchContextErrString (StmtCtxt DoExpr) = "'do' expression"
-matchContextErrString (StmtCtxt MDoExpr) = "'mdo' expression"
-matchContextErrString (StmtCtxt ListComp) = "list comprehension"
-matchContextErrString (StmtCtxt PArrComp) = "array comprehension"
+matchContextErrString (FunRhs fun) = "function " ++ showSDoc (ppr fun)
+matchContextErrString CaseAlt = "case"
+matchContextErrString PatBindRhs = "pattern binding"
+matchContextErrString RecUpd = "record update"
+matchContextErrString LambdaExpr = "lambda"
+matchContextErrString (StmtCtxt (ParStmtCtxt c)) = matchContextErrString (StmtCtxt c)
+matchContextErrString (StmtCtxt (PatGuard _)) = "pattern guard"
+matchContextErrString (StmtCtxt DoExpr) = "'do' expression"
+matchContextErrString (StmtCtxt MDoExpr) = "'mdo' expression"
+matchContextErrString (StmtCtxt ListComp) = "list comprehension"
+matchContextErrString (StmtCtxt PArrComp) = "array comprehension"
\end{code}