在子站点Yesod中使用AForm

时间:2015-05-20 17:05:53

标签: haskell yesod yesod-forms

我想在我的项目中为所有CRUD操作创建一个子网站,我有以下代码

{-# LANGUAGE FlexibleInstances     #-}

module Demo (
   module Demo.Data,
   module Demo
   )where

import Data.Maybe   (Maybe)


import Demo.Data
import Yesod
import Prelude (IO,($))

import Model
import Crud.FormsC


getDemoNewR :: Yesod master => HandlerT YesodDemo (HandlerT master IO) Html
getDemoNewR = do 
           (widget, encoding) <- generateFormPost $ renderBootstrap3 BootstrapBasicForm $ demoForm  Nothing
           defaultLayout $ do                        
                $(widgetFile "Exam/createExam") 

但有错误Not in scope: type constructor or class ‘Handler’

我无法导入Foundation,因为我生成了一个循环引用,因为我在Foundation.hs中有一个导入演示

import Demo
import Demo.Data 

data App = App
{ appSettings    :: AppSettings
, appStatic      :: Static -- ^ Settings for static file serving.
, appConnPool    :: ConnectionPool -- ^ Database connection pool.
, appHttpManager :: Manager
, appLogger      :: Logger
, getDemo        :: YesodDemo
}

那么有什么导入使用Handler o如何创建subSite?

1 个答案:

答案 0 :(得分:1)

当您在SubSite中时,请使用(HandlerT master IO)