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

Safe HaskellSafe
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 # 

Methods

bimap :: (a -> b) -> (c -> d) -> AccValidation a c -> AccValidation b d #

first :: (a -> b) -> AccValidation a c -> AccValidation b c #

second :: (b -> c) -> AccValidation a b -> AccValidation a c #

Bitraversable AccValidation Source # 

Methods

bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> AccValidation a b -> f (AccValidation c d) #

Bifoldable AccValidation Source # 

Methods

bifold :: Monoid m => AccValidation m m -> m #

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> AccValidation a b -> m #

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> AccValidation a b -> c #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> AccValidation a b -> c #

Swapped AccValidation Source # 

Methods

swapped :: (Profunctor p, Functor f) => p (AccValidation b a) (f (AccValidation d c)) -> p (AccValidation a b) (f (AccValidation c d)) #

Validate AccValidation Source # 

Methods

_AccValidation :: (Profunctor p, Functor f) => p (AccValidation e a) (f (AccValidation g b)) -> p (AccValidation e a) (f (AccValidation g b)) Source #

_Either :: (Profunctor p, Functor f) => p (Either e a) (f (Either g b)) -> p (AccValidation e a) (f (AccValidation g b)) Source #

Functor (AccValidation err) Source # 

Methods

fmap :: (a -> b) -> AccValidation err a -> AccValidation err b #

(<$) :: a -> AccValidation err b -> AccValidation err a #

Semigroup err => Applicative (AccValidation err) Source # 

Methods

pure :: a -> AccValidation err a #

(<*>) :: AccValidation err (a -> b) -> AccValidation err a -> AccValidation err b #

(*>) :: AccValidation err a -> AccValidation err b -> AccValidation err b #

(<*) :: AccValidation err a -> AccValidation err b -> AccValidation err a #

Foldable (AccValidation err) Source # 

Methods

fold :: Monoid m => AccValidation err m -> m #

foldMap :: Monoid m => (a -> m) -> AccValidation err a -> m #

foldr :: (a -> b -> b) -> b -> AccValidation err a -> b #

foldr' :: (a -> b -> b) -> b -> AccValidation err a -> b #

foldl :: (b -> a -> b) -> b -> AccValidation err a -> b #

foldl' :: (b -> a -> b) -> b -> AccValidation err a -> b #

foldr1 :: (a -> a -> a) -> AccValidation err a -> a #

foldl1 :: (a -> a -> a) -> AccValidation err a -> a #

toList :: AccValidation err a -> [a] #

null :: AccValidation err a -> Bool #

length :: AccValidation err a -> Int #

elem :: Eq a => a -> AccValidation err a -> Bool #

maximum :: Ord a => AccValidation err a -> a #

minimum :: Ord a => AccValidation err a -> a #

sum :: Num a => AccValidation err a -> a #

product :: Num a => AccValidation err a -> a #

Traversable (AccValidation err) Source # 

Methods

traverse :: Applicative f => (a -> f b) -> AccValidation err a -> f (AccValidation err b) #

sequenceA :: Applicative f => AccValidation err (f a) -> f (AccValidation err a) #

mapM :: Monad m => (a -> m b) -> AccValidation err a -> m (AccValidation err b) #

sequence :: Monad m => AccValidation err (m a) -> m (AccValidation err a) #

Alt (AccValidation err) Source # 

Methods

(<!>) :: AccValidation err a -> AccValidation err a -> AccValidation err a #

some :: Applicative (AccValidation err) => AccValidation err a -> AccValidation err [a] #

many :: Applicative (AccValidation err) => AccValidation err a -> AccValidation err [a] #

Semigroup err => Apply (AccValidation err) Source # 

Methods

(<.>) :: AccValidation err (a -> b) -> AccValidation err a -> AccValidation err b #

(.>) :: AccValidation err a -> AccValidation err b -> AccValidation err b #

(<.) :: AccValidation err a -> AccValidation err b -> AccValidation err a #

(Eq a, Eq err) => Eq (AccValidation err a) Source # 

Methods

(==) :: AccValidation err a -> AccValidation err a -> Bool #

(/=) :: AccValidation err a -> AccValidation err a -> Bool #

(Data a, Data err) => Data (AccValidation err a) Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AccValidation err a -> c (AccValidation err a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (AccValidation err a) #

toConstr :: AccValidation err a -> Constr #

dataTypeOf :: AccValidation err a -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (AccValidation err a)) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (AccValidation err a)) #

gmapT :: (forall b. Data b => b -> b) -> AccValidation err a -> AccValidation err a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AccValidation err a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AccValidation err a -> r #

gmapQ :: (forall d. Data d => d -> u) -> AccValidation err a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> AccValidation err a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> AccValidation err a -> m (AccValidation err a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AccValidation err a -> m (AccValidation err a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AccValidation err a -> m (AccValidation err a) #

(Ord a, Ord err) => Ord (AccValidation err a) Source # 

Methods

compare :: AccValidation err a -> AccValidation err a -> Ordering #

(<) :: AccValidation err a -> AccValidation err a -> Bool #

(<=) :: AccValidation err a -> AccValidation err a -> Bool #

(>) :: AccValidation err a -> AccValidation err a -> Bool #

(>=) :: AccValidation err a -> AccValidation err a -> Bool #

max :: AccValidation err a -> AccValidation err a -> AccValidation err a #

min :: AccValidation err a -> AccValidation err a -> AccValidation err a #

(Show a, Show err) => Show (AccValidation err a) Source # 

Methods

showsPrec :: Int -> AccValidation err a -> ShowS #

show :: AccValidation err a -> String #

showList :: [AccValidation err a] -> ShowS #

Semigroup e => Semigroup (AccValidation e a) Source #
((x <> y) <> z) == (x <> (y <> z :: AccValidation [String] Int))
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)

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 #

Methods

_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 #

Instances

Validate Either Source # 

Methods

_AccValidation :: (Profunctor p, Functor f) => p (AccValidation e a) (f (AccValidation g b)) -> p (Either e a) (f (Either g b)) Source #

_Either :: (Profunctor p, Functor f) => p (Either e a) (f (Either g b)) -> p (Either e a) (f (Either g b)) Source #

Validate AccValidation Source # 

Methods

_AccValidation :: (Profunctor p, Functor f) => p (AccValidation e a) (f (AccValidation g b)) -> p (AccValidation e a) (f (AccValidation g b)) Source #

_Either :: (Profunctor p, Functor f) => p (Either e a) (f (Either g b)) -> p (AccValidation e a) (f (AccValidation g b)) Source #