[Haskell-cafe] mtl tweaks

Ross Paterson ross at soi.city.ac.uk
Sun Jan 21 17:52:56 EST 2007

On Sun, Jan 21, 2007 at 12:37:02PM -0600, Nicolas Frisby wrote:
> I have another small mtl complaint: ReaderT, for example, requires the
> base type to be a Monad in order to make it a Functor. So it's Monad m
> => Functor (ReaderT r m) instead of Functor f => Functor (ReaderT r
> f), which is what's actually necessary for the instance. Remember, I
> did say _small_ complaint.
> I realize this has a bit to do with the class heirarchy and that's a
> sensitive issue. Regarding backwards compatibility and interface
> changes, note that the Monad m => Monad (ReaderT r m) instance would
> be unaffected by this... it's only the Functor => Functor instance. If
> someone wants to treat a transformed monad as a functor, then they're
> probably savvy enough to specify the base monad as a functor
> (especially with the @fmap f = (>>= return . f)@ recipe). They won't
> even see a difference unless they are rolling their own monad, since
> all mtl monads are also functors.

I agree.  I'd like to do the same thing with Applicative.

More information about the Haskell-Cafe mailing list