+ | only_one_alt alts
+ -- johan thinks that single case patterns should be on same line as case,
+ -- and no indent; all sane persons agree with him.
+ = let
+
+ ppr_alt (AlgAlts [] (BindDefault n _)) = (<>) (pMinBndr pe n) ppr_arrow
+ ppr_alt (PrimAlts [] (BindDefault n _)) = (<>) (pMinBndr pe n) ppr_arrow
+ ppr_alt (PrimAlts ((l, _):[]) NoDefault)= (<>) (pLit pe l) ppr_arrow
+ ppr_alt (AlgAlts ((con, params, _):[]) NoDefault)
+ = hsep [pCon pe con,
+ hsep (map (pMinBndr pe) params),
+ ppr_arrow]
+
+ ppr_rhs (AlgAlts [] (BindDefault _ expr)) = ppr_expr pe expr
+ ppr_rhs (AlgAlts ((_,_,expr):[]) NoDefault) = ppr_expr pe expr
+ ppr_rhs (PrimAlts [] (BindDefault _ expr)) = ppr_expr pe expr
+ ppr_rhs (PrimAlts ((_,expr):[]) NoDefault) = ppr_expr pe expr
+
+
+ ppr_arrow = ptext SLIT(" ->")
+ in
+ sep
+ [sep [pp_keyword, nest 4 (ppr_expr pe expr), text "of {", ppr_alt alts],
+ (<>) (ppr_rhs alts) (text ";}")]
+
+ | otherwise -- default "case" printing
+ = sep
+ [sep [pp_keyword, nest 4 (ppr_expr pe expr), ptext SLIT("of {")],
+ nest 2 (ppr_alts pe alts),
+ text "}"]
+ where
+ pp_keyword = case alts of
+ AlgAlts _ _ -> ptext SLIT("case")
+ PrimAlts _ _ -> ptext SLIT("case#")