[Haskell-beginners] Re: Debugging overlapping instances (mtl vs transformers)

Paolo Losi paolo.losi at gmail.com
Fri Sep 10 08:35:49 EDT 2010

Thanks Stephen,

On 09/09/2010 18:07, Stephen Tetley wrote:
> What package are you trying build? - at a pinch it looks like it has
> conflicting dependencies for the packages 'transformers' and mtl.

It was a (cabalized) project of mine.

I finally solved the problem.

My project depends on transformers and HTTP packages.
When you import Network.HTTP, it brings into scope:

instance Monad (Either e)

What I discovered is that:

- Not only the instance is in scope in the module that imports HTTP
   but in all project modules. That means that I cannot use
   Either as Monad Error in my modules (since that would trigger
   the overlapping instances error because it would conflict
   with transformers' instance).

- you cannot hide class instances for imported modules

- I was getting the overalapping instance error in a module
   that didn't import Network.HTTP. This is somewhat misleading
   because the imports in that module seemed safe.

- There is no way to discover quickly / automatically which
   import is causing the overlap. The best that I could do
   was to check the imports one by one in ghci and check with
   :info Either Either's instances. Is there a better/quicker way?

I'm reporting my finding to ask for a confirmation or get
advices on how to generally cope with this kind of errors.


More information about the Beginners mailing list