3 ms·
Right, here's my implementation in Haskell: f x y = case x of Left a -> Left a Right b -> case y of Left a -> L
by Twisol 8y ago
Right, here's my implementation in Haskell:
f x y =
case x of
Left a -> Left a
Right b ->
case y of
Left a -> Left a
Right c -> Right (b, c)
Each `case` represents a couple of hypothetical contexts, applying case analysis to the Either (the OR). You're going to have to duplicate some work, since the `Left a` branch appears twice and you're getting the `a` from different places.