数据构造函数不在范围内:无法识别的杂注
Data constructor not in scope: Unrecognised pragma
经过网站第一个项目后,我想添加一些静态页面,我检查了以下IHP - Recipes静态页面。我就是这样进行的:
在web/Types.hs
中我添加了以下内容:
data StaticController
= WelcomeAction
| AboutAction
deriving (Eq, Show, Data)
在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~ |]
在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
`
我得到的错误是:
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
| ^^^
您在名为 About
的数据类型中定义了视图。所以要渲染它,你会调用 render About
,而不是 render AboutView
.
我建议将 About
重命名为 AboutView
,这更符合 IHP 惯例:)
经过网站第一个项目后,我想添加一些静态页面,我检查了以下IHP - Recipes静态页面。我就是这样进行的:
在web/Types.hs
中我添加了以下内容:
data StaticController
= WelcomeAction
| AboutAction
deriving (Eq, Show, Data)
在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~ |]
在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
`
我得到的错误是:
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
| ^^^
您在名为 About
的数据类型中定义了视图。所以要渲染它,你会调用 render About
,而不是 render AboutView
.
我建议将 About
重命名为 AboutView
,这更符合 IHP 惯例:)