[Haskell-cafe] <|> that short-circuits in IO ?

Semen Trygubenko / Семен Тригубенко semen at trygub.com
Thu Oct 30 13:42:41 UTC 2014


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…)

Many thanks for your help,
Semen



-- 
Семен Тригубенко http://trygub.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20141030/7ecdc34f/attachment.sig>


More information about the Haskell-Cafe mailing list