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

Semen Trygubenko / Семен Тригубенко semen at trygub.com
Fri Oct 31 23:43:19 UTC 2014


On Sat, Nov 01, 2014 at 04:22:28AM +0700, Kim-Ee Yeoh wrote:
> On Thu, Oct 30, 2014 at 8:50 PM, Roman Cheplyaka <roma at ro-che.info> wrote:
> 
> > >> 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
> 
> 
> With the latest transformers, I still get
> 
> B
> A
> Right 42
> 
> i.e. the A hasn't been eliminated.
> 
> What am I missing?

In the actual use case
ErrorT was already wrapping IO and that's what I was combining with <|>, so,
for now, lacking the latest transformers, I have written a custom infix operator.

I haven't had a chance to test Roman's solution and assumed it to be correct.

So your observation is a valuable "data point" — thank you!

Apologies, I should have tested this myself sooner,
S.



-- 
Семен Тригубенко 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/20141031/c57c1877/attachment.sig>


More information about the Haskell-Cafe mailing list