【问题标题】:Yesod wai-eventsource example. Package dependency issue?Yesod wai-eventsource 示例。包依赖问题?
【发布时间】:2012-02-03 16:51:54
【问题描述】:

我正在尝试让this 示例代码在我的系统上编译。 当我尝试使用ghc Chat.hs 编译聊天模块时,ghc 给了我这个:

Chat.hs:76:39:
    Couldn't match expected type `Network.Wai.Request'
                with actual type `wai-0.4.3:Network.Wai.Request'
    In the second argument of `eventSourceApp', namely `req'
    In the second argument of `($)', namely `eventSourceApp chan req'
    In a stmt of a 'do' expression:
        res <- lift $ eventSourceApp chan req

我在 OS X Snow Leopard 上并清理了(一切?)除了 Haskell 平台,如下所示:

rm -r ~/.cabal
rm -r ~/.ghc
rm -r ~/Library/Haskell

并从 hackage 重新安装了 yesod 和 wai-eventsource。

据我了解,错误来自依赖问题。

    wai
    Synopsis: Web Application Interface.
    Default available version: 1.0.0
    Installed versions: 0.4.3, 1.0.0
    Homepage: https://github.com/yesodweb/wai
    License:  BSD3

其中 yesod-0.9.4.1 需要 wai == 0.4.* 而 wai-eventsource-1.0.0 需要 wai >= 1.0。

所以,我的问题是:现在是否可以让这个示例(使用 yesod 的官方版本)工作?随着所有的变化,yesod 项目正在通过 atm? 我是否必须更准确地了解我尝试安装的版本,如果需要,如何安装?


编辑:

我删除了~/.ghc(或者实际上遵循了here 给出的更严格的方法,以防万一)并尝试使用单个 cabal install yesod wai-eventsource 导致(不完整):

Resolving dependencies...
cabal: cannot configure yesod-0.9.4.1. It requires wai ==0.4.* and warp ==0.4.*
For the dependency on wai ==0.4.* there are these packages: wai-0.4.0,
wai-0.4.1, wai-0.4.2 and wai-0.4.3. However none of them are available.
wai-0.4.0 was excluded because wai-eventsource-1.0.0 requires wai >=1.0
...
wai-0.4.3 was excluded because wai-eventsource-1.0.0 requires wai >=1.0
For the dependency on warp ==0.4.* there are these packages: warp-0.4.0,
warp-0.4.0.1, warp-0.4.1, warp-0.4.1.1, warp-0.4.1.2, warp-0.4.2, warp-0.4.3,
warp-0.4.3.1, warp-0.4.4, warp-0.4.5, warp-0.4.6, warp-0.4.6.1, warp-0.4.6.2
and warp-0.4.6.3. However none of them are available.
warp-0.4.0 was excluded because wai-eventsource-1.0.0 requires warp >=1.0
...
warp-0.4.6.3 was excluded because wai-eventsource-1.0.0 requires warp >=1.0

在此之前(分别安装了 yesod 和 wai-eventsource)我尝试了 ghc -hide-package wai-1.0.0 Chat.hs 导致,

Chat.hs:77:39:
Couldn't match expected type `wai-1.0.0:Network.Wai.Request'
            with actual type `Network.Wai.Request'
In the second argument of `eventSourceApp', namely `req'
In the second argument of `($)', namely `eventSourceApp chan req'
In a stmt of a 'do' expression:
    res <- lift $ eventSourceApp chan req

【问题讨论】:

  • 一般来说,安装需要与单个cabal install 命令一起工作的软件包通常是个好主意,例如cabal install yesod wai-eventsource。这使得 Cabal 尝试选择每个包的单个版本,以便它们一起工作。单独安装,有时你最终会安装一个包的多个版本,导致这样的问题。

标签: haskell ghc cabal yesod


【解决方案1】:

我认为您需要注销(或隐藏)wai 1.0.0。当前的 Yesod 使用的是 wai 0.4,这是不匹配的来源。 (一旦发布了更新的 Yesod,这个问题就会消失。)

或者,您可以再次清除 ~/.ghc 文件夹并运行 cabal install yesod wai-eventsource,它应该只会自动安装兼容版本。

编辑:您还需要隐藏 wai-eventsource,可能还有其他一些。最简单的方法是运行ghc-pkg unregister wai-eventsource-1.0.0 --force。

【讨论】:

  • 如果我运行ghc-pkg unregister wai-eventsource-1.0.0 --force 命令,随后的ghc Chat.hs 会导致Could not find module Network.Wai.EventSource'` 错误。隐藏所需的包如何帮助编译这个模块?
  • 您没有安装 正确 版本的 wai-eventsource。这就是我推荐cabal install yesod wai-eventsource的原因。
  • 是的,但正如我在上面编辑过的问题中提到的那样,由于 both (wai/warp)==0.4.* 和(wai/warp)>=1.0.0 是必需的。如果这就是你的意思,那么在 wai-eventsource-1.0.0 之前没有关于 hackage 的版本。
  • Doh,我忘记了。您必须从 github 安装 wai-eventsource,或者等到 Yesod 本周发布。
猜你喜欢
  • 1970-01-01
  • 2021-11-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多