After going through the website first project, I wanted to add some static pages, I checked the following IHP - Recipes for static pages . That's how I proceded:
In web/Types.hs
I added the following:
data StaticController
= WelcomeAction
| AboutAction
deriving (Eq, Show, Data)
At Web/Static/About.hs
:
module Web.View.Static.About where
import Web.View.Prelude
data About = About
instance View About where
html About = [hsx| ~some html here~ |]
At Web/Controller/Static.hs
module Web.Controller.Static where
import Web.Controller.Prelude
import Web.View.Static.Welcome
import Web.View.Static.About
instance Controller StaticController where
action WelcomeAction = render WelcomeView
action AboutAction = render AboutView
`
The error I getting is :
Web/Controller/Static.hs:8:35
Data constructor not in scope: AboutView
|
| action AboutAction = render AboutView
|
build/Generated/Types.hs:3:1
Unrecognised pragma
|
| {-# GHC_OPTIONS -Wno-unused-imports, -Wno-dodgy-imports, -Wno-unused-matches #-}module Generated.Types where
| ^^^
You defined the view in a data type named About
. So to render it, you would call render About
, not render AboutView
.
I would recommend renaming About
to AboutView
, which fits the IHP conventions better :)