[Haskell-cafe] Re: not possible with monad transformers ?

Jules Bean jules at jellybean.co.uk
Wed Dec 1 06:23:28 EST 2004


On 30 Nov 2004, at 23:29, Ben Rudiak-Gould wrote:

> Jules Bean wrote:
>
>> However, your problem *does* have a natural underlying monad, if you 
>> care to use it.
>
> I may be confused, but I don't think it does. It seems like the OP 
> wants a type like
>
>    data Perhaps a = Success a | Failure [Error]

[snip]

> I don't see how to define (>>=) such that this will return the 
> appropriate value. If a1 fails you must call p in order to collect 
> additional errors, but there's no appropriate value of v1 that you can 
> pass.
>

Yes, I see I spoke too quickly.  Perhaps a = Success a | Failure 
[Error] is a monad, but the bind (>>=) operation doesn't do what the OP 
needs, since just like the bind for maybe, it will abort the 
computation when an error is returned.

But you can define combinators in this monad which do what the OP wants 
(and you did one of them in your message), it's just that haskell's do 
notation doesn't work, since the do notation is a shorthand for >>=, 
and >>= is the wrong strategy for this problem.

Jules




More information about the Haskell-Cafe mailing list