MTL vs Transformers?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

MTL vs Transformers?

Erik de Castro Lopo-34
Hi all,

I've just received the following error message:

  headers.hs:6:7:
    Could not find module `Control.Monad.Identity':
      it was found in multiple packages: transformers-0.1.4.0 mtl-1.1.0.2

I'm trying to use the Iteratee module which depends on Transformers
but I use MTL in other stuff.

Whats the preferred solution here?

Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: MTL vs Transformers?

Gregory Crosswhite-2
ghc-pkg hide transformers


On Oct 12, 2009, at 5:46 PM, Erik de Castro Lopo wrote:

> Hi all,
>
> I've just received the following error message:
>
>  headers.hs:6:7:
>    Could not find module `Control.Monad.Identity':
>      it was found in multiple packages: transformers-0.1.4.0  
> mtl-1.1.0.2
>
> I'm trying to use the Iteratee module which depends on Transformers
> but I use MTL in other stuff.
>
> Whats the preferred solution here?
>
> Erik
> --
> ----------------------------------------------------------------------
> Erik de Castro Lopo
> http://www.mega-nerd.com/
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: MTL vs Transformers?

Erik de Castro Lopo-34
Gregory Crosswhite wrote:

> ghc-pkg hide transformers

Here's an example. CGI uses MTL, Iteratee uses Transformers.

So, how do you use CGI and Iteratee in the same program?

Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: MTL vs Transformers?

Erik de Castro Lopo-34
Erik de Castro Lopo wrote:

> Gregory Crosswhite wrote:
>
> > ghc-pkg hide transformers
>
> Here's an example. CGI uses MTL, Iteratee uses Transformers.
>
> So, how do you use CGI and Iteratee in the same program?

CGI is just one of many examples. Text.Regex, Network.HTTP,
Database.HDBS.Sqlite, Tagsoup are others.

Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: MTL vs Transformers?

Gregory Crosswhite-2
In reply to this post by Erik de Castro Lopo-34
Ugh, I'm not as sure about that...  it took me long enough just to  
figure out "ghc-pkg hide transformers"!  :-)

Are running into problems because you need to refer to both packages  
(e.g., mtl and transformers) within your code, or because you are  
using packages that refer to each?  Because as long as you only need  
to refer to one of them in your own code, GHC should be able to handle  
the dependencies for the other packages correctly.  (Hiding the  
package only removes it from being automatically imported by your own  
code, it doesn't prevent it from being used by other packages that  
link to it.)

Cheers,
Greg

On Oct 12, 2009, at 6:08 PM, Erik de Castro Lopo wrote:

> Gregory Crosswhite wrote:
>
>> ghc-pkg hide transformers
>
> Here's an example. CGI uses MTL, Iteratee uses Transformers.
>
> So, how do you use CGI and Iteratee in the same program?
>
> Erik
> --
> ----------------------------------------------------------------------
> Erik de Castro Lopo
> http://www.mega-nerd.com/
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: MTL vs Transformers?

Erik de Castro Lopo-34
Gregory Crosswhite wrote:

> Are running into problems because you need to refer to both packages  
> (e.g., mtl and transformers) within your code, or because you are  
> using packages that refer to each?

The later. Iteratee uses Transformers and just about everything else
I want to use uses MTL.

> Because as long as you only need  
> to refer to one of them in your own code, GHC should be able to handle  
> the dependencies for the other packages correctly.  (Hiding the  
> package only removes it from being automatically imported by your own  
> code, it doesn't prevent it from being used by other packages that  
> link to it.)

That all seems a little hackish.

However after reading the hackage descriptions of both Transformers and
MTL, it seems that they share a very similar heritage. I therefore hacked
the iteratee.cabal file and replaced the build-depends on transformers
with one on mtl and the package built quite happily. I'll play with it
a bit to see if its working correctly.

Cheers,
Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: MTL vs Transformers?

Martijn van Steenbergen-2
Erik de Castro Lopo wrote:
> However after reading the hackage descriptions of both Transformers and
> MTL, it seems that they share a very similar heritage. I therefore hacked
> the iteratee.cabal file and replaced the build-depends on transformers
> with one on mtl and the package built quite happily. I'll play with it
> a bit to see if its working correctly.

I think the standard solutions are
* use Cabal for your project and/or
* use the PackageImports extension.

HTH,

Martijn.
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: MTL vs Transformers?

Erik de Castro Lopo-34
In reply to this post by Erik de Castro Lopo-34
Erik de Castro Lopo wrote:

> However after reading the hackage descriptions of both Transformers and
> MTL, it seems that they share a very similar heritage. I therefore hacked
> the iteratee.cabal file and replaced the build-depends on transformers
> with one on mtl and the package built quite happily. I'll play with it
> a bit to see if its working correctly.

Well Iteratee built with MTL passes all the tests that shipped with it
so I suppose it must be correct.

Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: MTL vs Transformers?

Ross Paterson
In reply to this post by Erik de Castro Lopo-34
On Tue, Oct 13, 2009 at 12:08:21PM +1100, Erik de Castro Lopo wrote:
> Here's an example. CGI uses MTL, Iteratee uses Transformers.
>
> So, how do you use CGI and Iteratee in the same program?

There should be no problem with that, as long as you build your program
using cabal.  Cabal will build each package exposing only the packages
it directly depends on.
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: MTL vs Transformers?

Ross Paterson
On Tue, Oct 13, 2009 at 08:43:12AM +0100, Ross Paterson wrote:
> On Tue, Oct 13, 2009 at 12:08:21PM +1100, Erik de Castro Lopo wrote:
> > Here's an example. CGI uses MTL, Iteratee uses Transformers.
> >
> > So, how do you use CGI and Iteratee in the same program?
>
> There should be no problem with that, as long as you build your program
> using cabal.  Cabal will build each package exposing only the packages
> it directly depends on.

Ah, I see: both packages have MonadIO and MonadTrans in their interface.
That will be a problem, which will only be fixed by the proposed
transition Ganesh mentioned.
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: MTL vs Transformers?

Daniel Schüssler
In reply to this post by Erik de Castro Lopo-34
On Tuesday 13 October 2009 02:46:29 Erik de Castro Lopo wrote:

> Hi all,
>
> I've just received the following error message:
>
>   headers.hs:6:7:
>     Could not find module `Control.Monad.Identity':
>       it was found in multiple packages: transformers-0.1.4.0 mtl-1.1.0.2
>
> I'm trying to use the Iteratee module which depends on Transformers
> but I use MTL in other stuff.
>
> Whats the preferred solution here?
>
> Erik
>

Hi,

alternative to ghc-pkg:

{-# LANGUAGE -XPackageImports #-}
module Blub where

import "mtl" Control.Monad.State

--
Daniel
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: MTL vs Transformers?

John Lato-2
In reply to this post by Erik de Castro Lopo-34
> From: Erik de Castro Lopo <[hidden email]>
>
> Well Iteratee built with MTL passes all the tests that shipped with it
> so I suppose it must be correct.
>

Unfortunately the iteratee tests aren't exhaustive, but if it builds
with MTL it should work.  I'm more surprised that it built just by
changing the .cabal file; I would expect you'd have to hack up the
imports in the source code.

John
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Re: MTL vs Transformers?

Erik de Castro Lopo-34
John Lato wrote:

> Unfortunately the iteratee tests aren't exhaustive, but if it builds
> with MTL it should work.  I'm more surprised that it built just by
> changing the .cabal file;

Nope, no hacking required beyond the .cabal file.

> I would expect you'd have to hack up the
> imports in the source code.

Thats actually the problem, MTL and Transformers both provide
Control.Monad.Identity, Control.Monad.Trans and possibly others.

Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe