mkToForm takes undefined instead of lists of EntityDef

This commit is contained in:
Michael Snoyman 2010-10-13 15:21:43 +02:00
parent 6d326855d9
commit eaffbb93ff

View File

@ -48,7 +48,7 @@ import Control.Monad ((<=<))
import Control.Monad.Trans.State import Control.Monad.Trans.State
import Control.Monad.Trans.Reader import Control.Monad.Trans.Reader
import Language.Haskell.TH.Syntax import Language.Haskell.TH.Syntax
import Database.Persist.Base (EntityDef (..)) import Database.Persist.Base (EntityDef (..), PersistEntity (entityDef))
import Data.Char (toUpper, isUpper) import Data.Char (toUpper, isUpper)
import Yesod.Widget import Yesod.Widget
import Control.Arrow ((&&&)) import Control.Arrow ((&&&))
@ -112,9 +112,10 @@ runFormGet f = do
gs <- reqGetParams `fmap` getRequest gs <- reqGetParams `fmap` getRequest
runFormGeneric gs [] f runFormGeneric gs [] f
-- | Create 'ToForm' instances for the entities given. In addition to regular 'EntityDef' attributes understood by persistent, it also understands label= and tooltip=. -- | Create 'ToForm' instances for the given entity. In addition to regular 'EntityDef' attributes understood by persistent, it also understands label= and tooltip=.
mkToForm :: [EntityDef] -> Q [Dec] mkToForm :: PersistEntity v => v -> Q [Dec]
mkToForm = mapM derive mkToForm =
fmap return . derive . entityDef
where where
afterPeriod s = afterPeriod s =
case dropWhile (/= '.') s of case dropWhile (/= '.') s of