haskell - 在 IHP 的 Helper 文件中正确导入
问题描述
我正在尝试将我的一些视图和控制器逻辑集中到它们各自的帮助文件中的帮助程序Application.Helper.Controller
和Application.Helper.View
.
我发现我无权访问我可以访问的包,例如在我的控制器文件中。例如Data.Text
和许多其他人一样。当我什至无法访问管道操作员时,我停止尝试将它们全部导入。
与View.hs
帮助文件相同,无法访问hsx
语法。
有没有简单的方法来解决这个问题?你如何解决这个问题?必须在此处手动进行导入吗?
对我来说,在文件夹中制作 Helper 文件似乎更简单,Web/Controller
因为该文件夹中的模块似乎可以毫无问题地进行正确的自动导入。
我的 Controller.hs 文件现在看起来,不支持 Data.Text 和管道运算符之类的东西:
module Application.Helper.Controller (
module IHP.LoginSupport.Helper.Controller
) where
-- Here you can add functions which are available in all your controllers
import IHP.LoginSupport.Helper.Controller
import Generated.Types
type instance CurrentUserRecord = User
和不支持 hsx 语法的 View.hs:
module Application.Helper.View (
-- To use the built in login:
module IHP.LoginSupport.Helper.View
) where
-- Here you can add functions which are available in all your views
-- To use the built in login:
import IHP.LoginSupport.Helper.View
解决方案
在Application.Helper.Controller
你需要 import IHP.ControllerPrelude
,像这样:
module Application.Helper.Controller (
module IHP.LoginSupport.Helper.Controller
) where
-- Here you can add functions which are available in all your controllers
import IHP.LoginSupport.Helper.Controller
import Generated.Types
import IHP.ControllerPrelude
type instance CurrentUserRecord = User
在Application.Helper.View
你需要 import IHP.ViewPrelude
,像这样:
module Application.Helper.View (
-- To use the built in login:
module IHP.LoginSupport.Helper.View
) where
-- Here you can add functions which are available in all your views
-- To use the built in login:
import IHP.LoginSupport.Helper.View
import IHP.ViewPrelude
这应该适当地添加到国际水文计划项目模板中。
推荐阅读
- api - 条件不工作(不和谐)
- dart - 可以颤振调用我自己的sdk
- reactjs - 变量 a = (罗马) 这种语法在 ReactJS 中是如何工作的?
- html - 为什么要使用加密算法来保护登录动作的安全?
- javascript - 在 typescript 中调用 rest API 时面临错误,因为“'this' 隐式具有类型'any',因为它没有类型注释”
- c# - DoubleAnimation/Storyboard 不会停止
- javascript - 避免重新渲染子组件 NgRx - Firestore
- python - 对脚本中的可执行文件运行 sudo 命令
- ios - 找不到故事板,带有模态的 ViewControllers Seques
- java - 在活动中保存数据