问题
I have the following code:
{-# 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
If run it in GHCI, it runs normally:
Ok, modules loaded: Simple.
*Simple> main
Application launched, listening on port 3000
But if run it as:
wai-handler-devel 3000 Simple withHelloWorld
the console reports an error:
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.
What could be the problem? Yesod is set and it displays in the output of ghc-pkg list
.
回答1:
On Unix systems remove ~/.ghc
directory and run:
ghc-pkg --global recache
On Windows systems (just suggestion) remove C:\Users\USERNAME\AppData\Roaming\ghc
and also recache from the command line (as Admin):
ghc-pkg --global recache
Not sure about Windows! Please check!
来源:https://stackoverflow.com/questions/14589358/could-not-find-module-yesod