digestive-functors-0.1.0.2: A general way to consume input using applicative functors

Text.Digestive.Forms

Synopsis

Documentation

class FormInput i f | i -> f whereSource

Class which all backends should implement. i is here the type that is used to represent a value uploaded by the client in the request

Methods

getInputString :: i -> Maybe StringSource

Parse the input into a string. This is used for simple text fields among other things

getInputStrings :: i -> [String]Source

Should be implemented

getInputText :: i -> Maybe TextSource

Parse the input value into Text

getInputTexts :: i -> [Text]Source

Can be overriden for efficiency concerns

getInputFile :: i -> Maybe fSource

Get a file descriptor for an uploaded file

inputStringSource

Arguments

:: (Monad m, Functor m, FormInput i f) 
=> (FormId -> Maybe String -> v)

View constructor

-> Maybe String

Default value

-> Form m i e v String

Resulting form

inputTextSource

Arguments

:: (Monad m, Functor m, FormInput i f) 
=> (FormId -> Maybe Text -> v)

View constructor

-> Maybe Text

Default value

-> Form m i e v Text

Resulting form

inputReadSource

Arguments

:: (Monad m, Functor m, FormInput i f, Read a, Show a) 
=> (FormId -> Maybe String -> v)

View constructor

-> e

Error when no read

-> Maybe a

Default input

-> Form m i e v a

Resulting form

inputBoolSource

Arguments

:: (Monad m, Functor m, FormInput i f) 
=> (FormId -> Bool -> v)

View constructor

-> Bool

Default input

-> Form m i e v Bool

Resulting form

inputChoiceSource

Arguments

:: (Monad m, Functor m, FormInput i f, Monoid v, Eq a) 
=> (FormId -> String -> Bool -> a -> v)

Choice constructor

-> a

Default option

-> [a]

Choices

-> Form m i e v a

Resulting form

inputChoicesSource

Arguments

:: (Monad m, Functor m, FormInput i f, Monoid v, Eq a) 
=> (FormId -> String -> Bool -> a -> v)

Choice constructor

-> [a]

Default choices

-> [a]

Choices

-> Form m i e v [a]

Resulting form

inputFileSource

Arguments

:: (Monad m, Functor m, FormInput i f) 
=> (FormId -> v)

View constructor

-> Form m i e v (Maybe f)

Resulting form

inputListSource

Arguments

:: (Monad m, Monoid v) 
=> Formlet m i e v Int

A formlet for the list length

-> Formlet m i e v a

The formlet for a single list element

-> Formlet m i e v [a]

The dynamic list formlet

Converts a formlet representing a single item into a formlet representing a dynamically sized list of those items. It requires that the user specify a formlet to hold the length of the list. Typically this will be a hidden field that is automatically updated by client-side javascript.

The field names must be generated as follows. Assume that if inputList had not been used, the field name would have been prefix-f5. In this case, the list length field name will be prefix-f5. The first item in the list will receive field names starting at prefix-f5.0.0. If each item is a composed form with two fields, those fields will have the names prefix-f5.0.0 and prefix-f5.0.1. The field names for the second item will be prefix-f5.1.0 and prefix-f5.1.1.