- input' :: Monad m => (String -> String -> xml) -> Maybe String -> Form xml m String
- inputM' :: Monad m => (String -> String -> xml) -> Maybe String -> Form xml m String
- optionalInput :: Monad m => (String -> xml) -> Form xml m (Maybe String)
- generalInput :: Monad m => (String -> Maybe String -> xml) -> Form xml m (Maybe String)
- generalInputMulti :: forall m xml. Monad m => (String -> [String] -> xml) -> Form xml m [String]
- inputFile :: Monad m => (String -> xml) -> Form xml m File
- fmapFst :: (t -> t1) -> (t, t2) -> (t1, t2)
- nothingIfNull :: (Monad m, Functor m) => Form xml m String -> Form xml m (Maybe String)
- check :: Monad m => Form xml m a -> (a -> Failing b) -> Form xml m b
- ensure :: Show a => (a -> Bool) -> String -> a -> Failing a
- ensures :: Show a => [(a -> Bool, String)] -> a -> Failing a
- ensureM :: (Monad m, Show a) => (a -> m Bool) -> String -> a -> m (Failing a)
- checkM :: Monad m => Form xml m a -> (a -> m (Failing b)) -> Form xml m b
- pureM :: (Monad m, Monoid xml) => m a -> Form xml m a
- runFormState :: Monad m => Env -> Form xml m a -> (m (Failing a), xml, FormContentType)
- massInput :: (Applicative m, Monad m, Monoid xml) => Formlet xml m a -> Formlet xml m [a]
- xml :: Monad m => xml -> Form xml m ()
- plug :: (xml -> xml1) -> Form xml m a -> Form xml1 m a
- plug2 :: Monad m => (xml -> xml1 -> xml2) -> (a -> b -> Failing c) -> Form xml m a -> Form xml1 m b -> Form xml2 m c
- plug' :: (xml1 -> xml2) -> Formlet xml1 m a -> Formlet xml2 m a
- type Env = [(String, Either String File)]
- data Form xml m a
- type Formlet xml m a = Maybe a -> Form xml m a
- data File = File {}
- data ContentType = ContentType {}
- data FormContentType
- = UrlEncoded
- | MultiPart
- data Rect = Rect {}
- stringRect :: Int -> String -> Rect
Documentation
:: Monad m | |
=> (String -> String -> xml) | function which takes the control name, the initial value, and returns the control markup |
-> Maybe String | optional default value |
-> Form xml m String |
Helper function for genereting input components based forms.
see also optionalInput
, generalInput
, and generalInputMulti
inputM' :: Monad m => (String -> String -> xml) -> Maybe String -> Form xml m StringSource
deprecated. See input'
:: Monad m | |
=> (String -> xml) | function which takes the form name and produces the control markup |
-> Form xml m (Maybe String) |
Create a form control which is not required to be successful
There is no way to provide a default value, because that would result in the control being successful.
For more information on successful controls see:
http://www.w3.org/TR/html401/interact/forms.html#successful-controls
see also input'
, generalInput
, and generalInputMulti
:: Monad m | |
=> (String -> Maybe String -> xml) | function which takes the control name, an initial value if one was found in the environment and returns control markup |
-> Form xml m (Maybe String) |
generate a form control
see also input'
, optionalInput
, generalInputMulti
.
generalInputMulti :: forall m xml. Monad m => (String -> [String] -> xml) -> Form xml m [String]Source
generate a form control which can return multiple values
Useful for controls such as checkboxes and multiple select .
see also input'
, optionalInput
, generalInput
.
:: Monad m | |
=> (String -> xml) | Generates the xml for the file-upload widget based on the name |
-> Form xml m File |
A File input widget.
nothingIfNull :: (Monad m, Functor m) => Form xml m String -> Form xml m (Maybe String)Source
Returns Nothing if the result is the empty String.
check :: Monad m => Form xml m a -> (a -> Failing b) -> Form xml m bSource
Check a condition or convert a result
:: Show a | |
=> (a -> Bool) | The predicate |
-> String | The error message, in case the predicate fails |
-> a | The value |
-> Failing a |
Apply a predicate to a value and return FR.Success or FR.Failure as appropriate
:: Show a | |
=> [(a -> Bool, String)] | List of predicate functions and error messages, in case the predicate fails |
-> a | The value |
-> Failing a |
Apply multiple predicates to a value, return FR.Success or all the FR.Failure messages
checkM :: Monad m => Form xml m a -> (a -> m (Failing b)) -> Form xml m bSource
Monadically check a condition or convert a result
:: Monad m | |
=> Env | A previously filled environment (may be empty) |
-> Form xml m a | The form |
-> (m (Failing a), xml, FormContentType) |
Runs the form state
:: (Applicative m, Monad m, Monoid xml) | |
=> Formlet xml m a | A formlet for a single a |
-> Formlet xml m [a] |
This generates a single (or more) forms for a, and a parser function for a list of a's.
plug2 :: Monad m => (xml -> xml1 -> xml2) -> (a -> b -> Failing c) -> Form xml m a -> Form xml1 m b -> Form xml2 m cSource
Combine the XML components of two forms using f, and combine the values using g.
(Functor m, Monad m) => Functor (Form xml m) | |
(Monad m, Applicative m, Monoid xml) => Applicative (Form xml m) |
File | |
|
data FormContentType Source
stringRect :: Int -> String -> RectSource
Choose a good number of rows for a textarea input. Uses the number of newlines in the string and the number of lines that are too long for the desired width.