@@ -817,17 +817,18 @@ arity1Branches bs = [([pat], guard, body) | MatchCase pat guard body <- bs]
817
817
groupCases ::
818
818
(Ord v ) =>
819
819
[MatchCase' () (Term3 v ann )] ->
820
- [([Pattern () ], [v ], [(Maybe (Term3 v ann ), Term3 v ann )])]
821
- groupCases = go0
820
+ [([Pattern () ], [v ], [(Maybe (Term3 v ann ), ([v ], Term3 v ann ))])]
821
+ groupCases = \ cases
822
+ [] -> []
823
+ ms@ ((p1, _, AbsN' vs1 _) : _) -> go (p1, vs1) [] ms
822
824
where
823
- go0 [] = []
824
- go0 ms@ ((p1, _, AbsN' vs1 _) : _) = go2 (p1, vs1) [] ms
825
- go2 (p0, vs0) acc [] = [(p0, vs0, reverse acc)]
826
- go2 (p0, vs0) acc ms@ ((p1, g1, AbsN' vs body) : tl)
827
- | p0 == p1 && vs == vs0 = go2 (p0, vs0) ((g1, body) : acc) tl
828
- | otherwise = (p0, vs0, reverse acc) : go0 ms
825
+ go (p0, vs0) acc [] = [(p0, vs0, reverse acc)]
826
+ go (p0, vs0) acc ms@ ((p1, g1, AbsN' vs body) : tl)
827
+ | p0 == p1 && vs == vs0 = go (p0, vs0) ((g1, (vs, body)) : acc) tl
828
+ | otherwise = (p0, vs0, reverse acc) : groupCases ms
829
829
830
830
printCase ::
831
+ forall m v .
831
832
(MonadPretty v m ) =>
832
833
Imports ->
833
834
DocLiteralContext ->
@@ -867,6 +868,7 @@ printCase im doc ms =
867
868
justified
868
869
justified = PP. leftJustify $ fmap (\ (g, b) -> (g, (arrow, b))) gbs
869
870
grid = traverse go (groupCases ms)
871
+ patLhs :: PrettyPrintEnv -> [v ] -> [Pattern () ] -> Pretty SyntaxText
870
872
patLhs ppe vs = \ cases
871
873
[pat] -> PP. group (fst (prettyPattern ppe (ac Annotation Block im doc) Bottom vs pat))
872
874
pats -> PP. group
@@ -899,7 +901,7 @@ printCase im doc ms =
899
901
-- like any other variable, ex: case Foo x y | x < y -> ...
900
902
PP. spaceIfNeeded (fmt S. DelimiterChar " |" )
901
903
<$> pretty0 (ac Control Normal im doc) g
902
- printBody = pretty0 (ac Annotation Block im doc)
904
+ printBody (vs, body) = withBoundTerms vs ( pretty0 (ac Annotation Block im doc) body )
903
905
904
906
-- A pretty term binding, split into the type signature (possibly empty) and the term.
905
907
data PrettyBinding = PrettyBinding
0 commit comments