Merge multiple cases in Haskell
2
With a case _ of
syntax like this:
fun a b c =
case (a, b, c) of
(Just True, Just _, _) -> foo
(Just True, _, Just _) -> foo
_ -> bar
Can I merge the first two conditions and avoid repeating foo
?
Alternatively, is there any other (cleaner) way to express that I want to run foo
if and only if a
is Just True
and either b
or c
are not Nothing
?
haskell pattern-matching
d = b or c
right before the case, and then do acase (a, d)
of(Just True, not Nothing) -> foo
? – rturrado Apr 29 at 22:58Maybe
values don't work like that withor
ornot
. – chepner Apr 29 at 23:02