ditto-0.3: ditto is a type-safe HTML form generation and validation library

Safe HaskellSafe
LanguageHaskell98

Ditto.Result

Description

Module for the core result type, and related functions

Synopsis

Documentation

data Result e ok Source #

Type for failing computations

Constructors

Error [(FormRange, e)] 
Ok ok 
Instances
Monad (Result e) Source # 
Instance details

Defined in Ditto.Result

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 # 
Instance details

Defined in Ditto.Result

Methods

fmap :: (a -> b) -> Result e a -> Result e b #

(<$) :: a -> Result e b -> Result e a #

Applicative (Result e) Source # 
Instance details

Defined in Ditto.Result

Methods

pure :: a -> Result e a #

(<*>) :: Result e (a -> b) -> Result e a -> Result e b #

liftA2 :: (a -> b -> c) -> Result e a -> Result e b -> Result e c #

(*>) :: Result e a -> Result e b -> Result e b #

(<*) :: Result e a -> Result e b -> Result e a #

(Eq e, Eq ok) => Eq (Result e ok) Source # 
Instance details

Defined in Ditto.Result

Methods

(==) :: Result e ok -> Result e ok -> Bool #

(/=) :: Result e ok -> Result e ok -> Bool #

(Show e, Show ok) => Show (Result e ok) Source # 
Instance details

Defined in Ditto.Result

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

Constructors

FormId 

Fields

  • String

    Global prefix for the form

  • (NonEmpty Int)

    Stack indicating field. Head is most specific to this item

FormIdCustom 

Fields

  • String

    Local name of the input

  • Int

    Index of the input

Instances
Eq FormId Source # 
Instance details

Defined in Ditto.Result

Methods

(==) :: FormId -> FormId -> Bool #

(/=) :: FormId -> FormId -> Bool #

Ord FormId Source # 
Instance details

Defined in Ditto.Result

Show FormId Source # 
Instance details

Defined in Ditto.Result

zeroId :: String -> FormId Source #

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

mapId :: (NonEmpty Int -> NonEmpty Int) -> FormId -> FormId Source #

map a function over the NonEmpty Int inside a FormId

data FormRange Source #

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

Constructors

FormRange FormId FormId 
Instances
Eq FormRange Source # 
Instance details

Defined in Ditto.Result

Show FormRange Source # 
Instance details

Defined in Ditto.Result

incrementFormId :: FormId -> FormId Source #

Increment a form ID

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