Could not find module `Yesod'

梦想的初衷 提交于 2019-12-10 18:54:48

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!