Posts

Showing posts with the label pattern-matching

Merge multiple cases in Haskell

2 1 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 Share Improve this question ...