proposal #4095: add Applicative instance for Either

Henning Thielemann schlepptop at henning-thielemann.de
Tue May 25 14:32:24 EDT 2010


Isaac Dupree schrieb:
> Either's Monad instance (whatever we decide the canonical instance ought
> to be*) should be in Control.Monad.Instances just like Either's Functor
> instance is.
> 
> * how many people use the current "(Error e) => Monad (Either e)"
> instance who would break if we change it?  If we don't like the Error
> class, then what do we replace it with? (Monad Maybe ignores the message
> -- but Monad (Either e) has to generate an "e", unless we let fail=error
> which may be an acceptable decision after all.  If we have a class to
> generate an "e", we could use that to make a MonadPlus instance too
> (mzero)... but even then, the Monad instance perhaps shouldn't depend on
> that class...)
> 
> Assuming we do want to keep Either having a Monad instance at all, we do
> as Ross says have to pick the "leftmost error" rather than "all errors"
> Applicative instance.  (Monad cannot produce errors beyond the leftmost,
> due to its later-actions-depend-on-results-from-earlier-ones nature.)

I can live without the Monad Either instance.


More information about the Libraries mailing list