Core types

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

- 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)
- isFormInput :: Monad m => FormState m i Bool
- newtype Form m i e v a = Form {}
- 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, Result e a)
- eitherForm :: Monad m => Form m i e v a -> String -> Environment m i -> m (Either v a)

# 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) |

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

isFormInput :: Monad m => FormState m i BoolSource

Check if any form input is present

A form represents a number of composed fields

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, Result e a) | Result |

Run a form

:: 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