6

I tried to import the Control.Monad.Writer module like this:

import Control.Monad.Writer

ghc version 7.4.1 gives the following error:

Ambiguous module name `Control.Monad.Writer':
      it was found in multiple packages: monads-tf-0.1.0.1 mtl-2.1.1

There is a question with a similar problem and a workaround here.

Despite the solution given in this thread my questions are:
Is this the standard configuration of cabal and ghc?
- If so: is there a reason for the module to be in two packages by default?
- If not: what (might have) happened and can it be undone?

If that matters: I'm working on Debian 7.3 wheezy and installed the haskell-platform package. Further, I installed some packages using cabal install.

Many thanks in advance!

Community
  • 1
  • 1
jules
  • 1,897
  • 2
  • 16
  • 19

1 Answers1

6

Yes, this is "standard". The reason is a historic refactoring of the mtl package to accomodate two different styles of handling type classes with multiple parameters, like the MonadWriter class : type families and functional dependencies.

The mtl package retains the older functional dependencies approach, whereas monads-tf has the newer type families approach.

As there are now libraries in the Haskell ecosystem that use monads-tf, it's inevitable that both will end up in the package database on typical installations - I've personally been experiencing it for several weeks.

Ganesh Sittampalam
  • 28,821
  • 4
  • 79
  • 98
  • 1
    Are you finding new packages written with `monads-tf`? I thought it was effectively deprecated by the popularity of `mtl`. Are you able to solve the issue with `PackageImports`? – J. Abrahamson Jan 15 '14 at 18:08
  • 1
    I hit this in ghci mostly. As the linked answers suggest, in cabal packages you just need to pick which to depend on. I haven't actually tracked down what pulled in monads-tf, I just know I have it :-) – Ganesh Sittampalam Jan 15 '14 at 18:10
  • 1
    From http://packdeps.haskellers.com/reverse/monads-tf, I suspect `MonadCatchIO-transformers` of being the indirect cause: http://packdeps.haskellers.com/reverse/MonadCatchIO-transformers – Ganesh Sittampalam Jan 15 '14 at 18:13
  • 5
    iirc, you can use `ghc-pkg hide monads-tf` to make mtl the default. This won't affect cabal packages, only ghci/ghc. – bennofs Jan 15 '14 at 18:18