[Haskell-cafe] [Haskell] Functor => Applicative => Monad
lennart at augustsson.net
Wed Dec 15 13:31:27 CET 2010
Yes, I think there should be a MonadFail distinct from MonadPlus.
Some types, like IO, are not in MonadPlus, but have a special implementation
of the fail method.
Personally, I think fail should just be removed, but that would break
The fail method was introduced for the wrong reasons (better error messages
was the excuse).
On Wed, Dec 15, 2010 at 11:51 AM, John Smith <voldermort at hotmail.com> wrote:
> On 15/12/2010 11:39, Lennart Augustsson wrote:
>> Any refutable pattern match in do would force MonadFail (or MonadPlus if
>> you prefer). So
>> 1. (MonadFail m) => a -> m a, \ a -> return a
>> 2. (MonadFail m) => m a, mfail "..."
>> 3. (MonadFail m) => Maybe a -> m a, \ a -> case a of Nothing -> mfail
>> "..."; Just x -> return x
>> 4. (Monad m) => a -> b -> m a, \ a b -> return a
>> 5. (Monad m) => (a, b) -> m a, \ (a, b) -> return a
>> As far as type inference and desugaring goes, it seems very little would
>> have to be changed in an implementation.
> Is there a need for a MonadFail, as distinct from mzero? fail always seems
> to be defined as error in ordinary monads, and as mzero in MonadPlus (or
> left at the default error).
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe