I know this seems a duplicate to Could not find module `Yesod', but unlike that user, ghc-pkg list
does not show Yesod
in its output on my computer, they didn't seem to be using stack
(I am, and I'm not sure if that means I don't need to worry about ghc-pkg list
), and additionally, the answer (code) to that question did not help my situation.
The Yesod Book has an example that I've been trying to get to work for several hours now. I'll reprint it here
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
import Yesod
data HelloWorld = HelloWorld
mkYesod "HelloWorld" [parseRoutes|
/ HomeR GET
|]
instance Yesod HelloWorld
getHomeR :: Handler Html
getHomeR = defaultLayout [whamlet|Hello World!|]
main :: IO ()
main = warp 3000 HelloWorld
I'm using the latest 64-bit Ubuntu OS. The problem I consistently run into is that runhaskell hello-world.hs
will time-and-time again return
hello-world.hs:6:18:
Could not find module `Yesod'
Use -v to see a list of the files searched for.
Likewise when I add a module
name to the file and try loading it with stack ghci hello-world.hs
. I'm using stack
to build things, and I've tried many different iterations of stack new
(with yesod templates), stack init
, and stack build
's left and right, with stack update
's here and there for good measure, and even a few cabal install
's, along with the entirety of the Yesod quickstart guide, all to no avail, and all within the proper directories.
When I use Yesod templates with simpleSQL
, the template site loads properly, and moreover a much larger project that I'm working with, Snowdrift, runs as well (albeit as a site, using stack exec yesod devel
and not a runhaskell FILE
command; but still, it works, and I've tried the exact same build process for handling the hello-world.hs
file above.
I feel like this problem has a simple solution that I'm missing, but I've tried and tried, and searched all over, and I just haven't come across an answer.
Thanks a bunch for taking the time to help me out.