【问题标题】:How can I use two versions of the same package?如何使用同一个包的两个版本?
【发布时间】:2012-08-02 21:24:55
【问题描述】:

我需要在 cabal 文件和或 Login.hs 中进行哪些更改? 请注意,此包中的其他 .hs 文件需要不同的管道版本。

(srchttps://github.com/gertcuykens/haskell-design)

gert@couchdb:~/Downloads/haskell-design/src$ ghci Chat.hs 
GHCi, version 7.4.2: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 2] Compiling Login            ( Login.hs, interpreted )

Login.hs:27:9:
    No instance for (Control.Monad.Trans.Control.MonadBaseControl
                       IO m0)
      arising from a use of `withManager'
    Possible fix:
      add an instance declaration for
      (Control.Monad.Trans.Control.MonadBaseControl IO m0)
    In the expression: withManager
    In the expression:
      withManager
      $ \ manager
          -> FB.runFacebookT app manager
             $ FB.getUserAccessTokenStep1 url perms
    In an equation for `fbUrl':
        fbUrl
          = withManager
            $ \ manager
                -> FB.runFacebookT app manager
                   $ FB.getUserAccessTokenStep1 url perms

Login.hs:27:55:
    Couldn't match expected type `http-conduit-1.4.1.8:Network.HTTP.Conduit.Manager.Manager'
                with actual type `http-conduit-1.5.0.3:Network.HTTP.Conduit.Manager.Manager'
    In the second argument of `FB.runFacebookT', namely `manager'
    In the expression: FB.runFacebookT app manager
    In the expression:
      FB.runFacebookT app manager $ FB.getUserAccessTokenStep1 url perms

Login.hs:31:13:
    No instance for (Control.Monad.Trans.Control.MonadBaseControl
                       IO m1)
      arising from a use of `withManager'
    Possible fix:
      add an instance declaration for
      (Control.Monad.Trans.Control.MonadBaseControl IO m1)
    In the expression: withManager
    In the expression:
      withManager
      $ \ manager
          -> FB.runFacebookT app manager
             $ do { t <- FB.getUserAccessTokenStep2 url [...];
                    u <- FB.getUser "me" [] (Just t);
                    .... }
    In an equation for `fbEmail':
        fbEmail c
          = withManager
            $ \ manager
                -> FB.runFacebookT app manager
                   $ do { t <- FB.getUserAccessTokenStep2 url ...;
                          .... }

Login.hs:31:59:
    Couldn't match expected type `http-conduit-1.4.1.8:Network.HTTP.Conduit.Manager.Manager'
                with actual type `http-conduit-1.5.0.3:Network.HTTP.Conduit.Manager.Manager'
    In the second argument of `FB.runFacebookT', namely `manager'
    In the expression: FB.runFacebookT app manager
    In the expression:
      FB.runFacebookT app manager
      $ do { t <- FB.getUserAccessTokenStep2 url [c];
             u <- FB.getUser "me" [] (Just t);
             return $ FB.userEmail u }

Login.hs:37:12:
    No instance for (Control.Monad.Trans.Control.MonadBaseControl
                       IO m2)
      arising from a use of `withManager'
    Possible fix:
      add an instance declaration for
      (Control.Monad.Trans.Control.MonadBaseControl IO m2)
    In the expression: withManager
    In the expression:
      withManager
      $ \ manager
          -> FB.runFacebookT app manager
             $ do { t <- FB.getUserAccessTokenStep2 url [...];
                    u <- FB.getUser "me" [] (Just t);
                    .... }
    In an equation for `fbName':
        fbName c
          = withManager
            $ \ manager
                -> FB.runFacebookT app manager
                   $ do { t <- FB.getUserAccessTokenStep2 url ...;
                          .... }

Login.hs:37:58:
    Couldn't match expected type `http-conduit-1.4.1.8:Network.HTTP.Conduit.Manager.Manager'
                with actual type `http-conduit-1.5.0.3:Network.HTTP.Conduit.Manager.Manager'
    In the second argument of `FB.runFacebookT', namely `manager'
    In the expression: FB.runFacebookT app manager
    In the expression:
      FB.runFacebookT app manager
      $ do { t <- FB.getUserAccessTokenStep2 url [c];
             u <- FB.getUser "me" [] (Just t);
             return $ FB.userName u }
Failed, modules loaded: none.
Prelude> 

【问题讨论】:

  • 能否将代码转换为全部使用相同版本的http-conduit
  • 运行ghc-pkg check,由于两个管道版本,您可能有许多损坏的包。在任何情况下,如果甚至可以根据同一个包的多个版本构建一个包,那么这样做是非常不可取的,您应该针对同一个管道版本构建所有依赖项。
  • ghc-pkg check 只给我分配这些东西Warning: haddock-interfaces: /home/gert/.cabal/share/doc/happstack-lite-7.2.0/html/happstack-lite.haddock doesn't exist or isn't a file
  • 我认为 happstack-server 使用 1.5 而 fb 使用 1.4?

标签: haskell dependencies dependency-management


【解决方案1】:

您可以在您的 cabal 文件中指定版本并使用 cabal-dev ghci(如果您使用 cabal-dev)。

你不能使用同一个包的两个版本,但你可以使用来自github的fb

$ git clone https://github.com/snoyberg/fb.git
$ cd fb
$ cabal install fb.cabal

【讨论】:

  • 但这仍然允许在同一个包中只有一个 http-conduit 版本,对吧?
  • 是的,这将是 cabal-dev 环境中的一个版本。
  • 我需要两个在同一个包中,happstack-server 使用 1.5 和 fb 1.4?
  • 我认为 https://github.com/snoyberg/fb.git 使用 1.5,我可以只安装 repo 吗?
  • thx ps 你能把答案改成:你不能使用 2 个 http-conduit 版本,但有一个 fb 的补丁 1) git clone https://github.com/snoyberg/fb.git 2) cd fb 3) cabal install fb.cabal跨度>
猜你喜欢
  • 2018-04-28
  • 2013-07-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多