3

我有以下代码:

{-# 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

4

1 回答 1

2

在 Unix 系统上删除~/.ghc目录并运行:

ghc-pkg --global recache

C:\Users\USERNAME\AppData\Roaming\ghc在 Windows 系统上(只是建议)从命令行删除并重新缓存(作为管理员):

ghc-pkg --global recache

不确定Windows!请检查!

于 2014-03-14T21:06:39.877 回答