Debugging overlapping instances (mtl vs transformers)

Hi all, I'm definitely stuck with the migration of my project from mtl to transformers. The use of transformer is mandated by a new dependency that I need to add. Overlapping instances for Monad (Either String) arising from a use of `tstampToForecasts' at ThreeLab/Gfs.hs:94:32-55 Matching instances: instance (Control.Monad.Trans.Error.Error e) => Monad (Either e) -- Defined in Control.Monad.Trans.Error instance Monad (Either e) -- Defined in mtl-1.1.1.0:Control.Monad.Error I really have no clue of who and why is bringing mtl instance in the scope. If I compile the file directly with: ghc -package monads-tf -package transformers -hide-package mtl ThreeLab/Gfs.hs -c I can successfully compile the module, so it seems the problem is not specific to that module. But the compilation fails if I do ghc -package monads-tf -package transformers -hide-package mtl --make Main.hs What's the best practice to debug this problem? What are the constraints of indirectly depending on both mtl and transformers? I'm really stuck :-/ Thanks Paolo

On 09/09/2010 10:35, Paolo Losi wrote:
Overlapping instances for Monad (Either String) arising from a use of `tstampToForecasts' at ThreeLab/Gfs.hs:94:32-55 Matching instances: instance (Control.Monad.Trans.Error.Error e) => Monad (Either e) -- Defined in Control.Monad.Trans.Error instance Monad (Either e) -- Defined in mtl-1.1.1.0:Control.Monad.Error
Forgot to say... that's the error I get using cabal build

Hi Paolo What package are you trying build? - at a pinch it looks like it has conflicting dependencies for the packages 'transformers' and mtl.

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. Thanks Paolo
participants (2)
-
Paolo Losi
-
Stephen Tetley