import Type ( Type )
import Var ( TyVar, Id )
import DataCon ( DataCon )
+import CStrings ( CLabelString, pprCLabelString )
import SrcLoc ( SrcLoc )
\end{code}
\begin{code}
data HsExpr id pat
= HsVar id -- variable
+ | HsIPVar id -- implicit parameter
| HsLit HsLit -- literal
| HsLitOut HsLit -- TRANSLATION
Type -- (with its type)
| HsLet (HsBinds id pat) -- let(rec)
(HsExpr id pat)
+ | HsWith (HsExpr id pat) -- implicit parameter binding
+ [(id, HsExpr id pat)]
+
| HsDo StmtCtxt
[Stmt id pat] -- "do":one or more stmts
SrcLoc
-- direct from the components
Bool -- boxed?
- | HsCon DataCon -- TRANSLATION; a saturated constructor application
- [Type]
- [HsExpr id pat]
-- Record construction
| RecordCon id -- The constructor
(HsRecordBinds id pat)
| RecordUpdOut (HsExpr id pat) -- TRANSLATION
- Type -- Type of *result* record (may differ from
+ Type -- Type of *result* record (may differ from
-- type of input record)
- [id] -- Dicts needed for construction
+ [id] -- Dicts needed for construction
(HsRecordBinds id pat)
| ExprWithTySig -- signature binding
(HsExpr id pat) -- (typechecked, of course)
(ArithSeqInfo id pat)
- | CCall FAST_STRING -- call into the C world; string is
+ | HsCCall CLabelString -- call into the C world; string is
[HsExpr id pat] -- the C function; exprs are the
-- arguments to pass.
Bool -- True <=> might cause Haskell
pprBinds b = pprDeeper (ppr b)
ppr_expr (HsVar v) = ppr v
+ppr_expr (HsIPVar v) = {- char '?' <> -} ppr v
ppr_expr (HsLit lit) = ppr lit
ppr_expr (HsLitOut lit _) = ppr lit
= sep [hang (ptext SLIT("let")) 2 (pprBinds binds),
hang (ptext SLIT("in")) 2 (ppr expr)]
+ppr_expr (HsWith expr binds)
+ = hsep [ppr expr, ptext SLIT("with"), ppr binds]
+
ppr_expr (HsDo do_or_list_comp stmts _) = pprDo do_or_list_comp stmts
ppr_expr (HsDoOut do_or_list_comp stmts _ _ _ _ _) = pprDo do_or_list_comp stmts
ppr_expr (ExplicitTuple exprs False)
= ptext SLIT("(#") <> sep (punctuate comma (map ppr_expr exprs)) <> ptext SLIT("#)")
-ppr_expr (HsCon con_id tys args)
- = ppr con_id <+> sep (map pprParendType tys ++
- map pprParendExpr args)
-
ppr_expr (RecordCon con_id rbinds)
= pp_rbinds (ppr con_id) rbinds
ppr_expr (RecordConOut data_con con rbinds)
ppr_expr (ELazyPat e) = char '~' <> pprParendExpr e
ppr_expr (EAsPat v e) = ppr v <> char '@' <> pprParendExpr e
-ppr_expr (CCall fun args _ is_asm result_ty)
+ppr_expr (HsCCall fun args _ is_asm result_ty)
= hang (if is_asm
- then ptext SLIT("_casm_ ``") <> ptext fun <> ptext SLIT("''")
- else ptext SLIT("_ccall_") <+> ptext fun)
+ then ptext SLIT("_casm_ ``") <> pprCLabelString fun <> ptext SLIT("''")
+ else ptext SLIT("_ccall_") <+> pprCLabelString fun)
4 (sep (map pprParendExpr args))
ppr_expr (HsSCC lbl expr)
HsLitOut l _ -> ppr l
HsVar _ -> pp_as_was
+ HsIPVar _ -> pp_as_was
ExplicitList _ -> pp_as_was
ExplicitListOut _ _ -> pp_as_was
ExplicitTuple _ _ -> pp_as_was
pp_rbinds thing rbinds
= hang thing
- 4 (braces (hsep (punctuate comma (map (pp_rbind) rbinds))))
+ 4 (braces (sep (punctuate comma (map (pp_rbind) rbinds))))
where
pp_rbind (v, e, pun_flag)
= getPprStyle $ \ sty ->
SrcLoc
| ReturnStmt (HsExpr id pat) -- List comps only, at the end
+
+consLetStmt :: HsBinds id pat -> [Stmt id pat] -> [Stmt id pat]
+consLetStmt EmptyBinds stmts = stmts
+consLetStmt binds stmts = LetStmt binds : stmts
\end{code}
\begin{code}