Skip to content
Snippets Groups Projects
Verified Commit 622119be authored by jan.hamal.dvorak's avatar jan.hamal.dvorak
Browse files

Introduce the Form type

parent e931e7d0
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,7 @@ module Hikaru.Form ...@@ -13,6 +13,7 @@ module Hikaru.Form
, FormElement(..) , FormElement(..)
, FormNote(..) , FormNote(..)
, FormT , FormT
, Form
, newForm , newForm
, getForm , getForm
, postForm , postForm
...@@ -94,6 +95,9 @@ where ...@@ -94,6 +95,9 @@ where
deriving (Functor, Applicative, Monad) deriving (Functor, Applicative, Monad)
type Form l m a = Maybe a -> FormT l m (Maybe a)
data Env data Env
= Env = Env
{ envPrefix :: [Text] { envPrefix :: [Text]
...@@ -175,7 +179,7 @@ where ...@@ -175,7 +179,7 @@ where
inputField :: (Monad m, ToParam a, FromParam a) inputField :: (Monad m, ToParam a, FromParam a)
=> Text -> l -> Maybe a -> FormT l m (Maybe a) => Text -> l -> Form l m a
inputField name label orig = do inputField name label orig = do
fullName <- makeName name fullName <- makeName name
textValue <- formParamMaybe fullName textValue <- formParamMaybe fullName
...@@ -193,7 +197,7 @@ where ...@@ -193,7 +197,7 @@ where
hiddenField :: (Monad m, ToParam a, FromParam a) hiddenField :: (Monad m, ToParam a, FromParam a)
=> Text -> Maybe a -> FormT l m (Maybe a) => Text -> Form l m a
hiddenField name orig = do hiddenField name orig = do
fullName <- makeName name fullName <- makeName name
textValue <- formParamMaybe fullName textValue <- formParamMaybe fullName
...@@ -208,7 +212,7 @@ where ...@@ -208,7 +212,7 @@ where
textField :: (Monad m, ToParam a, FromParam a) textField :: (Monad m, ToParam a, FromParam a)
=> Text -> l -> Maybe a -> FormT l m (Maybe a) => Text -> l -> Form l m a
textField name label orig = do textField name label orig = do
fullName <- makeName name fullName <- makeName name
textValue <- formParamMaybe fullName textValue <- formParamMaybe fullName
...@@ -226,7 +230,7 @@ where ...@@ -226,7 +230,7 @@ where
selectField :: (Monad m, ToParam a, FromParam a, Eq a) selectField :: (Monad m, ToParam a, FromParam a, Eq a)
=> Text -> l -> (a -> l) -> [a] -> Maybe a -> FormT l m (Maybe a) => Text -> l -> (a -> l) -> [a] -> Form l m a
selectField name label optlabel options orig = do selectField name label optlabel options orig = do
fullName <- makeName name fullName <- makeName name
value <- formParamMaybe fullName value <- formParamMaybe fullName
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment