restructuring the mtl

Stefan O'Rear stefanor at cox.net
Wed Mar 7 19:11:59 EST 2007


On Wed, Mar 07, 2007 at 11:59:24PM +0000, Ross Paterson wrote:
> I propose that we restructure and split the mtl into two packages:

Thank you, I was just thinking the same thing, but I would never have
thought to publically challenge the mtl folks :)

> mtl-base: a Haskell-98 package containing the monad transformers
> and non-overloaded versions of the operations, e.g.

Why can't we have:

class MonadTrans t where
  lift :: Monad m => m a -> t m a

looks perfectly H98 to me.  both ghci-6.7.20070223 -fno-glasgow-exts
and hugs +98 accept it. 

> mtl (depending on mtl-base): multi-parameter+FD type classes with
> instances for the transformers in mtl-base, e.g.

Would it also now be possible to get my metalift operation in mtl?

class MonadTrans t where
  lift :: Monad m => m a -> t m a
  metalift :: (Monad m, Monad m') => (forall a. m1 a -> m2 a) -> t m a -> t m' b

It is often useful in practice, for instance metalift lift can be used at type
State s a -> StateT s IO a (a suprisingly common request on #haskell).

Disclaimer: I have been able to write instances for all mtl
transformers *except ContT*, and it seems plausible that ContT may
force the class to be split. 

Stefan


More information about the Libraries mailing list