proposal #4095: add Applicative instance for Either
Bas van Dijk
v.dijk.bas at gmail.com
Tue May 25 13:08:26 EDT 2010
+1 for this Applicative instance.
I assume that when this instance is added to Control.Applicative, the
one in Control.Monad.Trans.Error from transformers will be removed.
On Tue, May 25, 2010 at 6:22 PM, Yitzchak Gale <gale at sefer.org> wrote:
> -1 for the orphan Monad instance with the silly
> superclass constraint that this Applicative instance
> is meant to extend
I assume you are referring to:
instance (Error e) => Monad (Either e) where
return = Right
Left l >>= _ = Left l
Right r >>= k = k r
fail msg = Left (strMsg msg)
defined in Control.Monad.Trans.Error from transformers or
Control.Monad.Error from mtl.
Thinking out loudly: since the 'fail' method is considered to be a
mistake, what about not defining it? As in:
instance Monad (Either e) where
return = Right
Left l >>= _ = Left l
Right r >>= k = k r
Regards,
Bas
More information about the Libraries
mailing list