Could iteratee depend on mtl instead of transformers?

Valery V. Vorotyntsev valery.vv at gmail.com
Mon Nov 16 18:15:34 EST 2009


Hi,

Iteratee [1] library depends on transformers [2]. The latter exposes
`Control.Monad.Trans' module.

  [1] http://hackage.haskell.org/package/iteratee-0.3.1
  [2] http://hackage.haskell.org/package/transformers-0.1.4.0

So does mtl [3] which is also installed on my system.

  [3] http://hackage.haskell.org/package/mtl-1.1.0.2

As a result, I cannot compile a program using Data.Iteratee, unless
one of the packages is hidden.

    $ ghci
    GHCi, version 6.10.4: http://www.haskell.org/ghc/  :? for help
    Loading package ghc-prim ... linking ... done.
    Loading package integer ... linking ... done.
    Loading package base ... linking ... done.
    Prelude> :m + Control.Monad.Trans
    Could not find module `Control.Monad.Trans':
      it was found in multiple packages: mtl-1.1.0.2 transformers-0.1.4.0

    $ ghci hide transformers-0.1.4.0

Having transformers hidden, I need to copy-paste MonadTrans and
MonadIO instances [4] from Data.Iteratee.Base to my code, otherwise I
get errors:

    Prelude> :load "/home/vvv/job/cdr.mscp/Codec/Binary/MSCP.hs"
    [1 of 1] Compiling Codec.Binary.MSCP (
/home/vvv/job/cdr.mscp/Codec/Binary/MSCP.hs, interpreted )

    /home/vvv/job/cdr.mscp/Codec/Binary/MSCP.hs:88:7:
        Could not deduce (MonadIO (IterateeG [] Word8 m))
          from the context (MonadIO m)
          arising from a use of `liftIO'
                       at /home/vvv/job/cdr.mscp/Codec/Binary/MSCP.hs:88:7-12
        Possible fix:
          add (MonadIO (IterateeG [] Word8 m)) to the context of
            the type signature for `warn'
          or add an instance declaration for (MonadIO (IterateeG [] Word8 m))
        In the first argument of `(.)', namely `liftIO'
        In the expression: liftIO . hPutStrLn stderr . ("*WARNING* " ++)
        In the definition of `warn':
            warn = liftIO . hPutStrLn stderr . ("*WARNING* " ++)
    Failed, modules loaded: none.

  [4] http://bit.ly/1TT37E

With MonadTrans & MonadIO instances duplicated, I need to use
`-fno-warn-orphans' GHC option in order not to see "orphan instance"
warnings.

Or I can just update iteratee.cabal and make it depend on mtl instead
of transformers:

    --- iteratee.cabal.orig 2009-11-09 20:40:29.000000000 +0200
    +++ iteratee.cabal      2009-11-16 18:32:36.637288144 +0200
    @@ -59,7 +59,7 @@
         containers            >= 0.2   && < 0.4,
         extensible-exceptions >= 0.1   && < 0.2,
         haskell98             >= 1     && < 2,
    -    transformers          >= 0.1.4 && < 0.2
    +    mtl                   >= 1.1   && < 1.2

       exposed-modules:
         Data.Iteratee

This allows me to remove Monad{Trans,IO} instances from my code and
forget about `-fno-warn-orphans' flag. But now my package cannot claim
its dependency on iteratee-0.3.1 any more.

Thus, the question is: are there any transformers-specific features
iteratee package needs, or can it just go with mtl?

				* * *

I suspect mtl to be more popular... And actual "popularity" can be
measured. I'll try to do that using cabal-query [5] tool; it allows to
list "reverse dependencies" [6].

  [5] http://hackage.haskell.org/package/cabal-query
  [6] http://hackage.haskell.org/trac/hackage/ticket/576#comment:2

Cheers.

-- 
vvv


More information about the Libraries mailing list