Safe Haskell | None |
---|

Core types

- newtype View e v = View {}
- data Environment m i
- = Environment (FormId -> m (Maybe i))
- | NoEnvironment

- fromList :: Monad m => [(FormId, i)] -> Environment m i
- type FormState m i a = ReaderT (Environment m i) (StateT FormRange m) a
- getFormId :: Monad m => FormState m i FormId
- getFormRange :: Monad m => FormState m i FormRange
- getFormInput :: Monad m => FormState m i (Maybe i)
- getFormInput' :: Monad m => FormId -> FormState m i (Maybe i)
- isFormInput :: Monad m => FormState m i Bool
- newtype Form m i e v a = Form {}
- type Formlet m i e v a = Maybe a -> Form m i e v a
- bracketState :: Monad m => FormState m i a -> FormState m i a
- incState :: Monad m => FormState m i ()
- view :: Monad m => v -> Form m i e v ()
- (++>) :: (Monad m, Monoid v) => Form m i e v () -> Form m i e v a -> Form m i e v a
- (<++) :: (Monad m, Monoid v) => Form m i e v a -> Form m i e v () -> Form m i e v a
- mapView :: (Monad m, Functor m) => (v -> w) -> Form m i e v a -> Form m i e w a
- runForm :: Monad m => Form m i e v a -> String -> Environment m i -> m (View e v, m (Result e a))
- runViewForm :: Monad m => Form m i e v a -> String -> Environment m i -> m (v, Maybe a)
- eitherForm :: Monad m => Form m i e v a -> String -> Environment m i -> m (Either v a)
- viewForm :: Monad m => Form m i e v a -> String -> m v

# Documentation

A view represents a visual representation of a form. It is composed of a function which takes a list of all errors and then produces a new view

data Environment m i Source

The environment is where you get the actual input per form. The environment itself is optional

Environment (FormId -> m (Maybe i)) | |

NoEnvironment |

Monad m => Monoid (Environment m i) |

fromList :: Monad m => [(FormId, i)] -> Environment m iSource

Create an environment from a lookup table

type FormState m i a = ReaderT (Environment m i) (StateT FormRange m) aSource

The form state is a state monad under which our applicatives are composed

getFormId :: Monad m => FormState m i FormIdSource

Utility function: returns the current `FormId`

. This will only make sense
if the form is not composed

getFormRange :: Monad m => FormState m i FormRangeSource

Utility function: Get the current range

getFormInput :: Monad m => FormState m i (Maybe i)Source

Utility function: Get the current input

getFormInput' :: Monad m => FormId -> FormState m i (Maybe i)Source

Gets the input of an arbitrary FormId.

isFormInput :: Monad m => FormState m i BoolSource

Check if any form input is present

A form represents a number of composed fields

type Formlet m i e v a = Maybe a -> Form m i e v aSource

A function for generating forms with an optional default value.

bracketState :: Monad m => FormState m i a -> FormState m i aSource

Insert a view into the functor

(++>) :: (Monad m, Monoid v) => Form m i e v () -> Form m i e v a -> Form m i e v aSource

Append a unit form to the left. This is useful for adding labels or error fields

(<++) :: (Monad m, Monoid v) => Form m i e v a -> Form m i e v () -> Form m i e v aSource

Append a unit form to the right. See `++>`

.

:: (Monad m, Functor m) | |

=> (v -> w) | Manipulator |

-> Form m i e v a | Initial form |

-> Form m i e w a | Resulting form |

Change the view of a form using a simple function

:: Monad m | |

=> Form m i e v a | Form to run |

-> String | Identifier for the form |

-> Environment m i | Input environment |

-> m (View e v, m (Result e a)) | Result |

Run a form

runViewForm :: Monad m => Form m i e v a -> String -> Environment m i -> m (v, Maybe a)Source

Evaluate a form, return view and a result if successful

:: Monad m | |

=> Form m i e v a | Form to run |

-> String | Identifier for the form |

-> Environment m i | Input environment |

-> m (Either v a) | Result |

Evaluate a form to it's view if it fails