dwayne/elm-form/1.0.0

Form.List

Provides a way to manage an ordered list of uniquely identifiable forms.

Forms

type Forms form

An ordered list of uniquely identifiable forms. The identifiers are automatically assigned and managed.

type alias Id =
Int

An identifier is represented by a non-negative integer.

Construct

empty : Forms form

Create an empty list of forms.

fromList : List form -> Forms form

Create an ordered list of uniquely identifiable forms derived from the given list of forms.

Accessors

get :
Id
-> (accessors -> Accessor state a)
-> Forms (Form state accessors error output)
-> Maybe a

Get the value of a property associated with the form identified by the given identifier.

If the form with the given identifier cannot be found then Nothing is returned.

set :
Id
-> (accessors -> Accessor state a)
-> a
-> Forms (Form state accessors error output)
-> Forms (Form state accessors error output)

Set the value of a property associated with the form identified by the given identifier.

If the form with the given identifier cannot be found then no change is made.

Id
-> (accessors -> Accessor state a)
-> (a -> a)
-> Forms (Form state accessors error output)
-> Forms (Form state accessors error output)

Modify the value of a property associated with the form identified by the given identifier.

If the form with the given identifier cannot be found then no change is made.

Id
-> (accessors -> state -> state)
-> Forms (Form state accessors error output)
-> Forms (Form state accessors error output)

Update the value of a property associated with the form identified by the given identifier.

If the form with the given identifier cannot be found then no change is made.

Change

prepend : form -> Forms form -> Forms form

Add a form to the start of the list.

append : form -> Forms form -> Forms form

Add a form to the end of the list.

remove : Id -> Forms form -> Forms form

Remove the form identified by the given identifier.

If the form with the given identifier cannot be found then no change is made.

Validate

(Id -> x -> y)
-> Forms (Form state accessors x output)
-> Validation y (List output)
(Id -> x -> y)
-> Forms (Form state accessors x output)
-> Maybe (List output)
(Id -> x -> y)
-> Forms (Form state accessors x output)
-> Result (List y) (List output)

Convert

toList : Forms form -> List ( Id, form )