我有以下代码:
{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses,
TemplateHaskell, OverloadedStrings #-}
module Simple where
import Yesod
data HelloWorld = HelloWorld
mkYesod "HelloWorld" [parseRoutes|
/ HomeR GET
|]
instance Yesod HelloWorld
getHomeR = defaultLayout [whamlet|Hello World!|]
withHelloWorld f = toWaiApp HelloWorld >>= f
main = warpDebug 3000 HelloWorld
如果在GHCI中运行它,它会正常运行:
Ok, modules loaded: Simple.
*Simple> main
Application launched, listening on port 3000
但如果将其作为:
运行wai-handler-devel 3000 Simple withHelloWorld
控制台报告错误:
pshuvaev@pshuvaev-K73SV:~/works/haskell/yesod/SimpleSite$ wai-handler-devel 3000 Simple.hs withHelloWorld
Attempting to interpret your app...
Compile failed:
Could not find module `Yesod'
Use -v to see a list of the files searched for.
可能是什么问题? Yesod已设置,它显示在ghc-pkg list
的输出中。
答案 0 :(得分:2)
在Unix系统上删除~/.ghc
目录并运行:
ghc-pkg --global recache
在Windows系统上(只是建议)删除C:\Users\USERNAME\AppData\Roaming\ghc
并从命令行重新缓存(作为管理员):
ghc-pkg --global recache
不确定Windows!请检查!