Please review this code:
case action1 of Right a -> a Left (Failure1 a) -> a Left (Failure2 a) -> case action2 a of Right a -> a _ -> error "Unexpected failure" _ -> error "Unexpected failure"
You can see that I have to repeat twice: with Right and with error cases.
How can I optimize this? Is it possible at all?
pattern-matching haskell
Nikita Volkov
source share