Module
Data.Validation.Semiring
- Package
- purescript-validation
- Repository
- purescript/purescript-validation
This module defines a variant of applicative validation with
an Alternative
instance, for validators which support errors
with multiple alternatives.
The API is equivalent to Data.Validation
,
but uses Semiring
instead of Semigroup
.
#V Source
data V err res
The V
functor, used for alternative validation
The Alternative
instance collects multiple failures in
an arbitrary Semiring
.
For example:
import Data.Semiring.Free
validate r :: Person -> V (Free Error) Person
validate person = { first: _, last: _, contact: _}
<$> validateName person.first
<*> validateName person.last
<*> (validateEmail person.contact <|> validatePhone person.contact)
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
(Semiring err) => Apply (V err)
(Semiring err) => Applicative (V err)
(Semiring err, Semigroup a) => Semigroup (V err a)
(Semiring err, Monoid a) => Monoid (V err a)
(Semiring err) => Alt (V err)
(Semiring err) => Plus (V err)
(Semiring err) => Alternative (V err)
Foldable (V err)
Traversable (V err)