formlets-0.5: Formlets implemented in Haskell

Text.Formlets

Synopsis

Documentation

input' :: Monad m => (String -> String -> xml) -> Maybe String -> Form xml m StringSource

Helper function for genereting input components based forms.

inputM' :: Monad m => (String -> String -> m xml) -> Maybe String -> Form xml m StringSource

optionalInput :: Monad m => (String -> xml) -> Form xml m (Maybe String)Source

inputFileSource

Arguments

:: Monad m 
=> (String -> xml)

Generates the xml for the file-upload widget based on the name

-> Form xml m File 

A File input widget.

fmapFst :: (t -> t2) -> (t, t1) -> (t2, t1)Source

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

ensureSource

Arguments

:: 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 Success or Failure as appropriate

ensuresSource

Arguments

:: 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 Success or all the Failure messages

ensureMSource

Arguments

:: (Monad m, Show a) 
=> (a -> m Bool)

The predicate

-> String

The error message, in case the predicate fails

-> a

The value

-> m (Failing a) 

checkM :: Monad m => Form xml m a -> (a -> m (Failing b)) -> Form xml m bSource

Monadically check a condition or convert a result

pureM :: (Monad m, Monoid xml) => m a -> Form xml m aSource

runFormStateSource

Arguments

:: Monad m 
=> Env

A previously filled environment (may be empty)

-> String

A prefix for the names

-> Form xml m a

The form

-> (m (Failing a), m xml, FormContentType) 

Runs the form state

massInput :: (Monoid xml, Applicative m, Monad m) => Form xml m (Maybe String) -> Form xml m a -> ([String] -> xml) -> Form xml m [a]Source

Takes a hidden-input field, a form of a and produces a list of a. | | The hidden input field contains a prefix, which is the pointer to the next form. | This form has to have the same variable-names as the original form, but prefixed by the prefix. | | Typically, some client-side code is needed to duplicate the original form and generate a unique prefix.

xml :: Monad m => xml -> Form xml m ()Source

Pure xml

plug :: (Monad m, Monoid xml) => (xml -> xml1) -> Form xml m a -> Form xml1 m aSource

Transform the XML component

withPrefix :: String -> Form xml m a -> Form xml m aSource

data Form xml m a Source

Instances

(Functor m, Monad m) => Functor (Form xml m) 
(Monad m, Applicative m, Monoid xml) => Applicative (Form xml m) 

data File Source

Constructors

File 

Instances