Haskell YesSource示例。包依赖性问题?

Haskell YesSource示例。包依赖性问题?,haskell,ghc,cabal,yesod,Haskell,Ghc,Cabal,Yesod,我试图在我的系统上编译示例代码。 当我尝试使用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'

我试图在我的系统上编译示例代码。 当我尝试使用
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
从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
(或者实际上遵循了一种更严格的方法,以防万一),并尝试使用单个
阴谋集团安装yesod wai eventsource
导致(不完整):

在此之前(分别安装了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
Chat.hs:77:39:
无法匹配预期的类型'wai-1.0.0:Network.wai.Request'
实际类型为“Network.Wai.Request”
在'eventSourceApp'的第二个参数中,即'req'
在“($)”的第二个参数中,即“eventSourceApp chan req”
在“do”表达式的stmt中:

res我认为您需要注销(或隐藏)wai 1.0.0。当前的Yesod使用wai 0.4,这就是不匹配的原因。(一旦发布新的Yesod,此问题将消失。)

或者,您可以再次清除~/.ghc文件夹并运行
cabal install-YesSource
,该程序将自动只安装兼容版本


编辑:您还需要隐藏wai事件源,可能还需要隐藏其他一些事件源。最简单的方法是运行
ghc pkg unregister wai-eventsource-1.0.0--force

作为一般规则,安装需要与单个
cabal install
命令协同工作的软件包通常是个好主意,例如
cabal install yesod wai eventsource
。这使得阴谋集团试图选择一个单一版本的每个包,使他们都在一起工作。单独安装时,有时会安装一个软件包的多个版本,导致如下问题。如果我运行
ghc pkg unregister wai-eventsource-1.0.0--force
命令,随后的
ghc Chat.hs
会导致
找不到模块
Network.wai.eventsource'`错误。隐藏所需的包如何帮助编译此模块?您没有安装正确版本的wai eventsource。这就是为什么我推荐
cabal install yesod wai eventsource
。是的,但正如我在上面编辑的问题中提到的,一个调用,正如建议的,会导致未解决的依赖项,因为(wai/warp)==0.4.*和(wai/warp)>=1.0.0都是必需的。如果这是你的意思的话,在wai-eventsource-1.0.0之前没有关于hackage的版本。你要么从github安装wai eventsource,要么等到Yesod本周发布。
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
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