4

我试图让这个示例代码在我的系统上编译。当我尝试用 编译 Chat 模块时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给出的更严格的方法,以防万一)并尝试使用单个安装包, 导致(不完整):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
4

1 回答 1

3

我认为您需要注销(或隐藏)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.

于 2012-02-04T19:06:02.050 回答