
30 Oct
2014
30 Oct
'14
1:50 p.m.
On 30/10/14 15:42, Semen Trygubenko / Семен Тригубенко wrote:
Dear Haskell-Cafe,
Is there a way to get Control.Applicative.<|> to short-circuit when combining two IO actions?
E.g.
let a = putStrLn "A" >> return (Left "hehe") let b = putStrLn "B" >> return (Right 42)
Prelude> liftA2 (<|>) a b
A B Right 42
liftA2 (<|>) b a
B A Right 42
(In the latter case I don't want A in the output…)
Wrap it into ExceptT (from the latest transformers), as in runExceptT $ ExceptT a <|> ExceptT b Roman