3

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.

dave4420
  • 46,404
  • 6
  • 118
  • 152
IPShuvaev
  • 41
  • 2
  • I'm not familiar with `wai-handler-devel` does it look at the local project's cabal file? – asm Jan 29 '13 at 21:01
  • What about just `runhaskell Simple.hs`? – pje Jan 29 '13 at 21:23
  • I do not have cabal file.. In the directory is only one file - Simple.hs. With runhaskell I try to run later. But on different, just installed operating system (Ubuntu 12.04) and the just installed haskell-platform and yesod this error does not occur. – IPShuvaev Jan 30 '13 at 09:15
  • if I run runhaskell, it works fine: `pshuvaev@pshuvaev-K73SV:~/works/haskell/yesod/SimpleSite$ runhaskell Simple.hs Application launched, listening on port 3000` – IPShuvaev Jan 30 '13 at 15:21

1 Answers1

2

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!

Jezen Thomas
  • 13,619
  • 6
  • 53
  • 91
crow16384
  • 587
  • 3
  • 15