我正在尝试在我的系统上编译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&gt; = 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
答案 0 :(得分: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
。