我正在尝试在我的系统上编译 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'
当我尝试使用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安装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我认为你需要取消注册(或隐藏)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.