我正在尝试关注this post来提供带有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
vs 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
答案 0 :(得分:2)
可能有十几种不同的方法来解决这个问题,但最简单的解决方案是取消注册所有损坏的软件包,取消注册两个版本的wai并再次安装所有软件包,确保您没有安装2个版本的wai。使用标志--dry-run确保cabal安装不安装旧版本。如果它确定它需要1.4并且不能使用2.0,则可能必须使用某些软件包的旧版本。