#4159: move Monad and MonadFix instances for Either from mtl
ross at soi.city.ac.uk
Wed Jun 30 03:58:40 EDT 2010
On Wed, Jun 30, 2010 at 09:36:00AM +0200, Claus Reinke wrote:
> Note that my opposition is against making 'Monad (Either a)' less
> defined and less tunable than it is at the moment.
It's a common trade-off: the Error constraint limits the instances that
are available, but gives you a bit more when you have an instance. One
must weigh the relative value of fail vs the unconstrained instance.
> One could also wonder whether the instance should be in Data.Either
> (the instance for Maybe is in Data.Maybe), [...]
The problem with that is that Haskell 98 does not define such an instance,
so a legal Haskell98 module that defined an instance itself would be broken
by an instance in a module imported by the Prelude.
> If you are just concerned about the Error constraint, simply provide
> a default instance that maps strMsg to error (see example of default
> instances with user override in base Data.Typable). That way, you'd
> get 'Monad (Either a)' without Error constraint, but with strictly more
> defined fail ('Left _|_' instead of '_|_'), and others can add even more
> defined fail when needed.
Do you mean an overlapping instance? There are problems with that too.
More information about the Libraries