reform-0.2.0: reform is an HTML form generation and validation library

Safe Haskell | Safe-Inferred

Text.Reform.Result

Description

Module for the core result type, and related functions

Synopsis

- data Result e ok
  - = Error [(FormRange, e)]
  - | Ok ok
- getResult :: Result e ok -> Maybe ok
- data FormId
- zeroId :: String -> FormId
- mapId :: ([Integer] -> [Integer]) -> FormId -> FormId
- formIdList :: FormId -> [Integer]
- data FormRange = FormRange FormId FormId
- incrementFormId :: FormId -> FormId
- unitRange :: FormId -> FormRange
- isInRange :: FormId -> FormRange -> Bool
- isSubRange :: FormRange -> FormRange -> Bool
- retainErrors :: FormRange -> [(FormRange, e)] -> [e]
- retainChildErrors :: FormRange -> [(FormRange, e)] -> [e]

# Documentation

data Result e ok Source

Type for failing computations

Constructors

Error [(FormRange, e)] |
Ok ok |

Instances

Monad (Result e) |
Functor (Result e) |
Applicative (Result e) |
(Eq e, Eq ok) => Eq (Result e ok) |
(Show e, Show ok) => Show (Result e ok) |

getResult :: Result e ok -> Maybe okSource

convert a `Result` to `Maybe` discarding the error message on `Error`

data FormId Source

An ID used to identify forms

Instances

Eq FormId |
Ord FormId |
Show FormId |

zeroId :: String -> FormId Source

The zero ID, i.e. the first ID that is usable

mapId :: ([Integer] -> [Integer]) -> FormId -> FormId Source

map a function over the `[Integer]` inside a `FormId`

formIdList :: FormId -> [Integer]Source

Stack indicating field. Head is most specific to this item

data FormRange Source

A range of ID's to specify a group of forms

Constructors

FormRange FormId FormId |

Instances

Eq FormRange |
Show FormRange |

incrementFormId :: FormId -> FormId Source

Increment a form ID

unitRange :: FormId -> FormRange Source

create a `FormRange` from a `FormId`

isInRange Source

Arguments

:: FormId | Id to check for
-> FormRange | Range
-> Bool | If the range contains the id

Check if a `FormId` is contained in a `FormRange`

isSubRange Source

Arguments

:: FormRange | Sub-range
-> FormRange | Larger range
-> Bool | If the sub-range is contained in the larger range

Check if a `FormRange` is contained in another `FormRange`

retainErrors :: FormRange -> [(FormRange, e)] -> [e]Source

Select the errors for a certain range

retainChildErrors :: FormRange -> [(FormRange, e)] -> [e]Source

Select the errors originating from this form or from any of the children of this form