[Haskell-cafe] Re: Using the ContT monads for early exits of IO ?

Maciej Piechotka uzytkownik2 at gmail.com
Fri Jun 11 14:20:12 EDT 2010


On Thu, 2010-06-10 at 21:21 +0100, Ben Millwood wrote:
> On Thu, Jun 10, 2010 at 8:57 PM, Maciej Piechotka <uzytkownik2 at gmail.com> wrote:
> >
> > Error monad seems not to be a semantic solution as we exit on success
> > not failure.
> >
> 
> Which is really why the Either monad should not necessarily have Error
> associations :)
> If you forget about the fail method, the Monad (Either e) instance
> doesn't need the e to be an error type.
> 
> Alternatively, if even Error is more information than you need, you
> could use MaybeT:
> 
> http://hackage.haskell.org/package/MaybeT
> 
> which allows you to just stop. Given you're using it with IO it'd be
> easy to write a result to an IORef before terminating the computation,
> so it's of equivalent power, if slightly less convenient.

Over MaybeT I would prefer to simply iterate over list using helper
recursive function.

Either monad (without Error part) seems to be good solution - and it do
not contain too much information.

But the function with ContT IO seemed... nice. Also as it deals with
network I/O speed does not seems to be a great issue.

Regards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100611/616b2090/attachment.bin


More information about the Haskell-Cafe mailing list