--- special case: let ... in let ...
-pprExpr sty (HsLet binds expr@(HsLet _ _))
- = ppSep [ppHang (ppPStr SLIT("let")) 2 (ppCat [ppr sty binds, ppPStr SLIT("in")]),
- ppr sty expr]
-
-pprExpr sty (HsLet binds expr)
- = ppSep [ppHang (ppPStr SLIT("let")) 2 (ppr sty binds),
- ppHang (ppPStr SLIT("in")) 2 (ppr sty expr)]
-
-pprExpr sty (HsDo stmts _)
- = ppCat [ppPStr SLIT("do"), ppAboves (map (ppr sty) stmts)]
-
-pprExpr sty (HsIf e1 e2 e3 _)
- = ppSep [ppCat [ppPStr SLIT("if"), ppNest 2 (pprExpr sty e1), ppPStr SLIT("then")],
- ppNest 4 (pprExpr sty e2),
- ppPStr SLIT("else"),
- ppNest 4 (pprExpr sty e3)]
-
-pprExpr sty (ExplicitList exprs)
- = ppBracket (ppInterleave ppComma (map (pprExpr sty) exprs))
-pprExpr sty (ExplicitListOut ty exprs)
- = ppBesides [ ppBracket (ppInterleave ppComma (map (pprExpr sty) exprs)),
- ifnotPprForUser sty (ppBeside ppSP (ppParens (pprGenType sty ty))) ]
-
-pprExpr sty (ExplicitTuple exprs)
- = ppParens (ppInterleave ppComma (map (pprExpr sty) exprs))
-pprExpr sty (ExprWithTySig expr sig)
- = ppHang (ppBesides [ppLparen, ppNest 2 (pprExpr sty expr), ppPStr SLIT(" ::")])
- 4 (ppBeside (ppr sty sig) ppRparen)
-
-pprExpr sty (RecordCon con rbinds)
- = pp_rbinds sty (ppr sty con) rbinds
-
-pprExpr sty (RecordUpd aexp rbinds)
- = pp_rbinds sty (pprParendExpr sty aexp) rbinds
-
-pprExpr sty (ArithSeqIn info)
- = ppBracket (ppr sty info)
-pprExpr sty (ArithSeqOut expr info)
- = case sty of
- PprForUser ->
- ppBracket (ppr sty info)
- _ ->
- ppBesides [ppLbrack, ppParens (ppr sty expr), ppr sty info, ppRbrack]
-
-pprExpr sty (TyLam tyvars expr)
- = ppHang (ppCat [ppStr "/\\", interppSP sty tyvars, ppStr "->"])
- 4 (pprExpr sty expr)
-
-pprExpr sty (TyApp expr [ty])
- = ppHang (pprExpr sty expr) 4 (pprParendGenType sty ty)
-
-pprExpr sty (TyApp expr tys)
- = ppHang (pprExpr sty expr)
- 4 (ppBracket (interpp'SP sty tys))
-
-pprExpr sty (DictLam dictvars expr)
- = ppHang (ppCat [ppStr "\\{-dict-}", interppSP sty dictvars, ppStr "->"])
- 4 (pprExpr sty expr)
-
-pprExpr sty (DictApp expr [dname])
- = ppHang (pprExpr sty expr) 4 (ppr sty dname)
-
-pprExpr sty (DictApp expr dnames)
- = ppHang (pprExpr sty expr)
- 4 (ppBracket (interpp'SP sty dnames))
-
-pprExpr sty (ClassDictLam dicts methods expr)
- = ppHang (ppCat [ppStr "\\{-classdict-}",
- ppBracket (interppSP sty dicts),
- ppBracket (interppSP sty methods),
- ppStr "->"])
- 4 (pprExpr sty expr)
-
-pprExpr sty (Dictionary dicts methods)
- = ppSep [ppBesides [ppLparen, ppPStr SLIT("{-dict-}")],
- ppBracket (interpp'SP sty dicts),
- ppBesides [ppBracket (interpp'SP sty methods), ppRparen]]
-
-pprExpr sty (SingleDict dname)
- = ppCat [ppPStr SLIT("{-singleDict-}"), ppr sty dname]
+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 (ExplicitList exprs)
+ = brackets (fsep (punctuate comma (map ppr_expr exprs)))
+ppr_expr (ExplicitListOut ty exprs)
+ = hcat [ brackets (fsep (punctuate comma (map ppr_expr exprs))),
+ ifNotPprForUser ((<>) space (parens (pprType ty))) ]
+
+ppr_expr (ExplicitTuple exprs boxity)
+ = tupleParens boxity (sep (punctuate comma (map ppr_expr exprs)))
+
+ppr_expr (RecordCon con_id rbinds)
+ = pp_rbinds (ppr con_id) rbinds
+ppr_expr (RecordConOut data_con con rbinds)
+ = pp_rbinds (ppr con) rbinds
+
+ppr_expr (RecordUpd aexp rbinds)
+ = pp_rbinds (pprParendExpr aexp) rbinds
+ppr_expr (RecordUpdOut aexp _ _ rbinds)
+ = pp_rbinds (pprParendExpr aexp) rbinds
+
+ppr_expr (ExprWithTySig expr sig)
+ = hang (nest 2 (ppr_expr expr) <+> dcolon)
+ 4 (ppr sig)
+
+ppr_expr (ArithSeqIn info)
+ = brackets (ppr info)
+ppr_expr (ArithSeqOut expr info)
+ = brackets (ppr info)
+
+ppr_expr EWildPat = char '_'
+ppr_expr (ELazyPat e) = char '~' <> pprParendExpr e
+ppr_expr (EAsPat v e) = ppr v <> char '@' <> pprParendExpr e
+
+ppr_expr (HsCCall fun args _ is_asm result_ty)
+ = hang (if is_asm
+ then ptext SLIT("_casm_ ``") <> pprCLabelString fun <> ptext SLIT("''")
+ else ptext SLIT("_ccall_") <+> pprCLabelString fun)
+ 4 (sep (map pprParendExpr args))
+
+ppr_expr (HsSCC lbl expr)
+ = sep [ ptext SLIT("_scc_") <+> doubleQuotes (ptext lbl), pprParendExpr expr ]
+
+ppr_expr (TyLam tyvars expr)
+ = hang (hsep [ptext SLIT("/\\"), interppSP tyvars, ptext SLIT("->")])
+ 4 (ppr_expr expr)
+
+ppr_expr (TyApp expr [ty])
+ = hang (ppr_expr expr) 4 (pprParendType ty)
+
+ppr_expr (TyApp expr tys)
+ = hang (ppr_expr expr)
+ 4 (brackets (interpp'SP tys))
+
+ppr_expr (DictLam dictvars expr)
+ = hang (hsep [ptext SLIT("\\{-dict-}"), interppSP dictvars, ptext SLIT("->")])
+ 4 (ppr_expr expr)
+
+ppr_expr (DictApp expr [dname])
+ = hang (ppr_expr expr) 4 (ppr dname)
+
+ppr_expr (DictApp expr dnames)
+ = hang (ppr_expr expr)
+ 4 (brackets (interpp'SP dnames))
+
+ppr_expr (HsType id) = ppr id
+