Change CaseAlt and LambdaExpr to FunRhs in deriving Foldable and Traversable (#20496)
Fix for #20496 (closed) as well as some other cleanups.
Derived instances for Foldable
and Traversable
used to generate FunBind
s with CaseAlt
and LambdaExpr
in them which caused panic in pprMatch
and weird pretty printing output like this:
instance Foldable T where
\ f z (MkT a1) -> f a1 z -- lambda match?
f -> f a1 -- case match?
null (MkT _) = False
I couldn't find a reason why LambdaExpr
and CaseAlt
were used there, but replacing them with FunRhs
worked out nicely, no more panics and the pretty printing output makes more sense:
instance Foldable T where
foldr f z (MkT a1) = f a1 z
foldMap f (MkT a1) = f a1
null (MkT _) = False