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

ariep ariep at xs4all.nl
Tue Mar 10 09:50:22 EDT 2009


Hi,


==== 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.

==== 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.

What is the recommended way to deal with module name conflicts, such as
this one?


Regards,

Arie

BTW: how can I let the user edit a line of text, from a non-empty starting
value for the text? (In other words, actually *edit* a line, not enter a
new one.) I currently do this by adding the starting value to the user's
history, so he/she can get it by pressing the up arrow key. This is clearly
not optimal.



More information about the Haskell-Cafe mailing list