我试图让这个示例代码在我的系统上编译。当我尝试用 编译 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