reform-0.2.7.1: reform is a type-safe HTML form generation and validation library

Safe Haskell | Safe
Language | Haskell98

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) Source # |
Methods (>>=) :: Result e a -> (a -> Result e b) -> Result e b # (>>) :: Result e a -> Result e b -> Result e b # return :: a -> Result e a # fail :: String -> Result e a #
Functor (Result e) Source # |
Methods fmap :: (a -> b) -> Result e a -> Result e b # (<$) :: a -> Result e b -> Result e a #
Applicative (Result e) Source # |
Methods pure :: a -> Result e a # (<*>) :: Result e (a -> b) -> Result e a -> Result e b # (*>) :: Result e a -> Result e b -> Result e b # (<*) :: Result e a -> Result e b -> Result e a #
(Eq ok, Eq e) => Eq (Result e ok) Source # |
Methods (==) :: Result e ok -> Result e ok -> Bool # (/=) :: Result e ok -> Result e ok -> Bool #
(Show ok, Show e) => Show (Result e ok) Source # |
Methods showsPrec :: Int -> Result e ok -> ShowS # show :: Result e ok -> String # showList :: [Result e ok] -> ShowS #

getResult :: Result e ok -> Maybe ok Source #

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

data FormId Source #

An ID used to identify forms

Instances

Eq FormId Source # |
Methods (==) :: FormId -> FormId -> Bool # (/=) :: FormId -> FormId -> Bool #
Ord FormId Source # |
Methods compare :: FormId -> FormId -> Ordering # (<) :: FormId -> FormId -> Bool # (<=) :: FormId -> FormId -> Bool # (>) :: FormId -> FormId -> Bool # (>=) :: FormId -> FormId -> Bool # max :: FormId -> FormId -> FormId # min :: FormId -> FormId -> FormId #
Show FormId Source # |
Methods showsPrec :: Int -> FormId -> ShowS # show :: FormId -> String # showList :: [FormId] -> ShowS #

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 Source # |
Methods (==) :: FormRange -> FormRange -> Bool # (/=) :: FormRange -> FormRange -> Bool #
Show FormRange Source # |
Methods showsPrec :: Int -> FormRange -> ShowS # show :: FormRange -> String # showList :: [FormRange] -> ShowS #

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