#4159: move Monad and MonadFix instances for Either from mtl to base

Claus Reinke claus.reinke at talk21.com
Tue Jun 29 18:13:07 EDT 2010


>>> The proposal is to move the Monad and MonadFix instances for Either
>>> (currently in the mtl package) to Control.Monad.Instances and
>>> Control.Monad.Fix respectively (both in the base package).  The Monad
>>> instance is still an orphan, to retain Haskell 98 compatibility, but the
>>> MonadFix instance is together with its class.  The Error constraint is
>>> removed from both instances, and the default definition of fail is used.
>>
>> -1, because the default definition of fail is error, which would
>> render the Monad instance useless (unless I'm missing something?).
>
> You would just use Left instead of 'fail' if you want to show failure in 
> an Either value.

a) you are suggesting to bypass a method of the proposed Monad
    instance because it isn't useful, I am suggesting not to define a
    Monad instance with unusable methods
b) desugaring of pattern-match failure in Monads calls fail, not Left

Claus

PS. I just remembered that I have used 'Monad (Either a)', for
    'a' other than String (a parser with error information in addition
    to plain error message). That application didn't use
    Control.Monad.Errror or Control.Monad.Instances - it could
    have been made to fit the current Control.Monad.Error design
    but not the proposed design, because it relied on
    'fail s `mplus` return x == return x'.

 



More information about the Libraries mailing list