我正试图跟踪这个职位,以便使用scotty提供静态文件。所以我有一个小剧本:
{-# LANGUAGE OverloadedStrings #-}
import Web.Scotty
import Network.Wai.Middleware.Static
import Data.Monoid (mconcat)
main = scotty 3000 $ do
middleware $ staticPolicy (noDots >-> addBase "static")
get "/:word" $ do
beam <- param "word"
html $ mconcat ["<h1>Scotty, ", beam, " me up!</h1>"]运行ghc会产生以下错误:
server.hs:9:16:
Couldn't match type `Network.Wai.Internal.Request'
with `wai-1.4.0.1:Network.Wai.Request'
Expected type: wai-1.4.0.1:Network.Wai.Middleware
Actual type: Network.Wai.Middleware
In the return type of a call of `staticPolicy'
In the second argument of `($)', namely
`staticPolicy (noDots >-> addBase "static")'
In a stmt of a 'do' block:
middleware $ staticPolicy (noDots >-> addBase "static")现在我不明白如何解释wai-1.4.0.1:Network.Wai.Middleware与Network.Wai.Middleware之间的关系。这是版本问题吗?我试着检查安装的库,但没有发现任何冲突。
我该查些什么才能解决这个问题?
编辑
运行ghc-pkg list wai会给我提供如下信息:
C:\perso\prog\haskell\orgmode\orgmodeserver\src\hs>ghc-pkg list wai
WARNING: there are broken packages. Run 'ghc-pkg check' for more details.
C:/Program Files (x86)/Haskell Platform/2013.2.0.0\lib\package.conf.d:
C:\Users\sberg\AppData\Roaming\ghc\i386-mingw32-7.6.3\package.conf.d:
wai-1.4.0.1
wai-2.0.0运行ghc-pkg check (跳过一系列警告):
The following packages are broken, either because they have a problem
listed above, or because they depend on a broken package.
scion-browser-0.2.17
miamtime-0.0.0
TestYes-0.0.0
yesod-platform-1.2.2
yesod-1.2.1.1
yesod-auth-1.2.0.2
yesod-form-1.3.0.1发布于 2014-02-17 10:41:00
可能有十几种不同的方法来解决这个问题,但最简单的解决方案是注销所有损坏的包,注销wai的两个版本,然后重新安装所有的包,确保您没有安装wai的两个版本。使用标志-试运行,以确保阴谋安装没有安装旧版本。如果它决定需要1.4而不能使用2.0,那么您可能不得不使用一些包的旧版本。
https://stackoverflow.com/questions/21824426
复制相似问题