different flavours of Monad Template Library

Ross Paterson ross at soi.city.ac.uk
Sun Jan 4 18:50:28 EST 2009


On Sun, Jan 04, 2009 at 11:22:15PM +0100, Henning Thielemann wrote:
> I see now at least three MTL libraries at hackage, namely
>   mtl
>   mmtl
>   mtl-tf
>
>  They all define both the example data types and according type classes 
> in modules with the same name. This way you can only use one of these  
> packages in all packages you import. However the data types are defined  
> the same way in the packages, only the classes differ.
>
>  I wished, there would be one package defining only the datatypes, say  
> "mtl-data", and three ones with the names "mtl", "mmtl", "mtl-tf" that  
> define their classes with corresponding instances. These classes should 
> be in different modules, so you can use different class frameworks in the 
> same project. The data type package would be useful on its own and could  
> be run on the simplest Haskell compilers, since no functional 
> dependencies are required.

I agree.  I had a go at such a restructuring of mtl a while ago:

	http://darcs.haskell.org/packages/transformers/
	http://darcs.haskell.org/packages/mtl-split/

The first is a Haskell 98 package that defines the monad transformers,
operations and liftings, like the mtl-data suggestion.  The second adds
the FD-based classes.  It's close to complete compatibility with mtl,
except that State is a synonym for StateT Identity etc.  The main
problem was haddock's limitations with inter-package re-exports.

>  However there is the compatibility problem: Currently 
> Control.Monad.State exports also the MonadState class, which would no 
> longer work. Maybe we can reserve Control.Monad.State for mtl, which 
> exports Control.Monad.State.Data.Lazy from mtl-data and 
> Control.Monad.State.Class from mtl.

I used Control.Monad.Trans.State.Lazy for the transformer.


More information about the Libraries mailing list