【发布时间】: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 尝试选择每个包的单个版本,以便它们一起工作。单独安装,有时你最终会安装一个包的多个版本,导致这样的问题。