[Haskell-cafe] Incompatibility of different (monad transformer) libraries

Henning Thielemann lemming at henning-thielemann.de
Fri Mar 13 21:14:53 EDT 2009


On Tue, 10 Mar 2009, ariep wrote:

> ==== Problem instance ====
>
> In my code, I use some monad transformers. I used to use the "mtl" package,
> but I recently switched to the combination "transformers"/"monads-tf"
> (mainly for the Applicative instances).
>
> The same code also uses the "haskeline" library, for line reading.
> Haskeline allows to edit the user's history (previously entered lines), but
> only through a Control.Monad.State interface, and that happens to be the
> Control.Monad.State from "mtl". So now, my package also needs to import
> "mtl".
>
> This combination of package dependencies gives import conflicts: whenever I
> import some Control.Monad.{State,Error,Cont,...} module, there is more than
> one package providing such a module.

I think 'transformers' exports Control.Monad.Trans.State. This should not 
conflict with MTL. However, MTL's State type is different from 
transformer's one. Is that your problem?

> ==== Solution? ====
>
> For now, I resolve the ambiguity by using "Package imports", i.e. annotate
> the ambiguous imports by the right package name.
>
> Is this the best solution? The ghc manual states, that the package import
> extension should not be necessary. I can think of another solution, by
> creating a dedicated package, which imports mtl:Control.Monad.* and
> re-exports them under another name, but that's even less elegant than
> package imports.

Since the 'cabal' tool became better and better, today I use a cabal file 
even for small programs. Cabal automatically calls GHC with the right 
package exposing and hiding options.


More information about the Haskell-Cafe mailing list