-pprMatches :: (NamedThing id, Outputable id, Outputable pat)
- => (Bool, SDoc) -> [Match flexi id pat] -> SDoc
-
-pprMatches print_info@(is_case, name) [match]
- = if is_case then
- pprMatch is_case match
- else
- name <+> (pprMatch is_case match)
-
-pprMatches print_info (match1 : rest)
- = ($$) (pprMatches print_info [match1])
- (pprMatches print_info rest)
-
----------------------------------------------
-pprMatch :: (NamedThing id, Outputable id, Outputable pat)
- => Bool -> Match flexi id pat -> SDoc
-
-pprMatch is_case first_match
- = sep [(sep (map (ppr) row_of_pats)),
- grhss_etc_stuff]
- where
- (row_of_pats, grhss_etc_stuff) = ppr_match is_case first_match
-
- ppr_match is_case (PatMatch pat match)
- = (pat:pats, grhss_stuff)
- where
- (pats, grhss_stuff) = ppr_match is_case match
-
- ppr_match is_case (GRHSMatch grhss_n_binds)
- = ([], pprGRHSsAndBinds is_case grhss_n_binds)
-
- ppr_match is_case (SimpleMatch expr)
- = ([], text (if is_case then "->" else "=") <+> ppr expr)
-
-----------------------------------------------------------
-
-pprGRHSsAndBinds :: (NamedThing id, Outputable id, Outputable pat)
- => Bool -> GRHSsAndBinds flexi id pat -> SDoc
-
-pprGRHSsAndBinds is_case (GRHSsAndBindsIn grhss binds)
- = ($$) (vcat (map (pprGRHS is_case) grhss))
- (if (nullBinds binds)
- then empty
- else vcat [ text "where", nest 4 (pprDeeper (ppr binds)) ])
-
-pprGRHSsAndBinds is_case (GRHSsAndBindsOut grhss binds ty)
- = ($$) (vcat (map (pprGRHS is_case) grhss))
- (if (nullBinds binds)
- then empty
- else vcat [text "where", nest 4 (pprDeeper (ppr binds)) ])
-
----------------------------------------------
-pprGRHS :: (NamedThing id, Outputable id, Outputable pat)
- => Bool -> GRHS flexi id pat -> SDoc
+pprMatches :: (Outputable id, Outputable pat)
+ => (Bool, SDoc) -> [Match id pat] -> SDoc
+pprMatches print_info matches = vcat (map (pprMatch print_info) matches)
+
+
+pprMatch :: (Outputable id, Outputable pat)
+ => (Bool, SDoc) -> Match id pat -> SDoc
+pprMatch print_info@(is_case, name) (Match _ pats maybe_ty grhss)
+ = maybe_name <+> sep [sep (map ppr pats),
+ ppr_maybe_ty,
+ nest 2 (pprGRHSs is_case grhss)]
+ where
+ maybe_name | is_case = empty
+ | otherwise = name
+ ppr_maybe_ty = case maybe_ty of
+ Just ty -> dcolon <+> ppr ty
+ Nothing -> empty
+
+
+pprGRHSs :: (Outputable id, Outputable pat)
+ => Bool -> GRHSs id pat -> SDoc
+pprGRHSs is_case (GRHSs grhss binds maybe_ty)
+ = vcat (map (pprGRHS is_case) grhss)
+ $$
+ (if nullBinds binds then empty
+ else text "where" $$ nest 4 (pprDeeper (ppr binds)))
+
+
+pprGRHS :: (Outputable id, Outputable pat)
+ => Bool -> GRHS id pat -> SDoc