different flavours of Monad Template Library

Henning Thielemann lemming at henning-thielemann.de
Sun Jan 4 17:22:15 EST 2009


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.
  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 assume that mmtl and mtl-tf are not as much used as mtl, such 
that it would not too bad to break compatibility for them. They could no 
longer export Control.Monad.State, but instead the user of mmtl has to 
import Control.Monad.State.Data from mtl-data. The class file of mmtl 
could be named Control.Monad.Modular.State.Class. (Replace "State" by 
"Writer", "Reader" and so on, and "mmtl" by "mtl-tf" in order to get all 
names that need to be adapted.)


More information about the Libraries mailing list