Module
Data.Validation.Semigroup
- Package
- purescript-validation
- Repository
- purescript/purescript-validation
This module defines an applicative functor for applicative validation.
Applicative validation differs from monadic validation using Either
in
that it allows us to collect multiple errors using a Semigroup
, whereas
Either
terminates on the first error.
#V Source
data V err result
The V
functor, used for applicative validation
The Applicative
instance collects multiple failures in
an arbitrary Semigroup
.
For example:
validate :: Person -> V (Array Error) Person
validate person = { first: _, last: _, email: _ }
<$> validateName person.first
<*> validateName person.last
<*> validateEmail person.email
Instances
(Eq err, Eq result) => Eq (V err result)
(Ord err, Ord result) => Ord (V err result)
(Show err, Show result) => Show (V err result)
Functor (V err)
Bifunctor V
(Semigroup err) => Apply (V err)
(Semigroup err) => Applicative (V err)
(Semigroup err, Semigroup a) => Semigroup (V err a)
(Semigroup err, Monoid a) => Monoid (V err a)
Foldable (V err)
Traversable (V err)