proposal #4095: add Applicative instance for Either

Isaac Dupree ml at
Tue May 25 14:23:50 EDT 2010

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.)


More information about the Libraries mailing list