validation-0.5.2: A data-type like Either but with an accumulating Applicative

Safe HaskellNone
LanguageHaskell2010

Data.Validation

Contents

Description

Data types similar to Data.Either that are explicit about failure and success.

Synopsis

Data types

data AccValidation err a Source

A value of the type err or a, however, the Applicative instance accumulates values. This is witnessed by the Semigroup context on the instance. Note that there is no Monad such that ap = (*).

>>> _Success # (+1) <*> _Success # 7 :: AccValidation String Int
AccSuccess 8
>>> _Failure # ["f1"] <*> _Success # 7 :: AccValidation [String] Int
AccFailure ["f1"]
>>> _Success # (+1) <*> _Failure # ["f2"] :: AccValidation [String] Int
AccFailure ["f2"]
>>> _Failure # ["f1"] <*> _Failure # ["f2"] :: AccValidation [String] Int
AccFailure ["f1","f2"]

Constructors

AccFailure err 
AccSuccess a 

Instances

Bifunctor AccValidation Source 
Bitraversable AccValidation Source 
Bifoldable AccValidation Source 
Swapped AccValidation Source 
Validate AccValidation Source 
Functor (AccValidation err) Source 
Semigroup err => Applicative (AccValidation err) Source 
Foldable (AccValidation err) Source 
Traversable (AccValidation err) Source 
Semigroup err => Alt (AccValidation err) Source 
Semigroup err => Apply (AccValidation err) Source 
(Eq err, Eq a) => Eq (AccValidation err a) Source 
(Data err, Data a) => Data (AccValidation err a) Source 
(Ord err, Ord a) => Ord (AccValidation err a) Source 
(Show err, Show a) => Show (AccValidation err a) Source 
Monoid e => Monoid (AccValidation e a) Source
((x `mappend` y) `mappend` z) == (x `mappend` (y `mappend` z :: AccValidation [String] Int))
mempty `mappend` x == (x :: AccValidation [String] Int)
x `mappend` mempty == (x :: AccValidation [String] Int)
Semigroup e => Semigroup (AccValidation e a) Source
((x <> y) <> z) == (x <> (y <> z :: AccValidation [String] Int))

data Validation err a Source

A value of the type err or a and isomorphic to Data.Either.

>>> _Success # (+1) <*> _Success # 7 :: Validation String Int
Success 8
>>> _Failure # ["f1"] <*> _Success # 7 :: Validation [String] Int
Failure ["f1"]
>>> _Success # (+1) <*> _Failure # ["f2"] :: Validation [String] Int
Failure ["f2"]
>>> _Failure # ["f1"] <*> _Failure # ["f2"] :: Validation [String] Int
Failure ["f1"]

Constructors

Failure err 
Success a 

data ValidationT err m a Source

The transformer version of Validation.

Constructors

ValidationT 

Fields

runValidationT :: m (Validation err a)
 

data ValidationB m err a Source

The bifunctor version of ValidationT

Constructors

ValidationB 

Fields

runValidationB :: m (Validation err a)
 

Prisms

_Failure :: Validate f => Prism (f e1 a) (f e2 a) e1 e2 Source

_Success :: Validate f => Prism (f e a) (f e b) a b Source

Isomorphisms

class Validate f where Source

Minimal complete definition

Nothing

Methods

_Validation :: Iso (f e a) (f g b) (Validation e a) (Validation g b) Source

_Validation' :: Iso (f e a) (f g b) (Validation' e a) (Validation' g b) Source

_AccValidation :: Iso (f e a) (f g b) (AccValidation e a) (AccValidation g b) Source

_Either :: Iso (f e a) (f g b) (Either e a) (Either g b) Source