either-5.0.3: Combinators for working with sums

Copyright | (c) 2014 Chris Allen Edward Kmett
License | BSD-style
Maintainer | ekmett@gmail.com
Stability | provisional
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Either.Validation

Description

Monoidal `Validation` sibling to `Either`.

Synopsis

- data Validation e a
  - = Failure e
  - | Success a
- _Success :: forall c a b p f. (Choice p, Applicative f) => p a (f b) -> p (Validation c a) (f (Validation c b))
- _Failure :: forall a c b p f. (Choice p, Applicative f) => p a (f b) -> p (Validation a c) (f (Validation b c))
- eitherToValidation :: Either e a -> Validation e a
- validationToEither :: Validation e a -> Either e a
- _Validation :: forall e a g b p f. (Profunctor p, Functor f) => p (Either e a) (f (Either g b)) -> p (Validation e a) (f (Validation g b))
- vap :: Semigroup m => Either m (a -> b) -> Either m a -> Either m b
- ealt :: Validation e a -> Validation e a -> Validation e a
- vapm :: Monoid m => Either m (a -> b) -> Either m a -> Either m b
- apm :: Monoid m => Validation m (a -> b) -> Validation m a -> Validation m b

# Documentation

data Validation e a Source #

`Validation` is `Either` with a Left that is a `Monoid`

Constructors

Failure e |
Success a |

#### Instances

Instances details

Bifoldable Validation Source # |
Instance details Defined in Data.Either.Validation Methods bifold :: Monoid m => Validation m m -> m Source # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Validation a b -> m Source # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Validation a b -> c Source # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Validation a b -> c Source #
Bifunctor Validation Source # |
Instance details Defined in Data.Either.Validation Methods bimap :: (a -> b) -> (c -> d) -> Validation a c -> Validation b d Source # first :: (a -> b) -> Validation a c -> Validation b c Source # second :: (b -> c) -> Validation a b -> Validation a c Source #
Bitraversable Validation Source # |
Instance details Defined in Data.Either.Validation Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Validation a b -> f (Validation c d) Source #
(Semigroup e, Monoid e) => Alternative (Validation e) Source # |
Instance details Defined in Data.Either.Validation Methods empty :: Validation e a Source # (<|>) :: Validation e a -> Validation e a -> Validation e a Source # some :: Validation e a -> Validation e [a] Source # many :: Validation e a -> Validation e [a] Source #
Semigroup e => Applicative (Validation e) Source # |
Instance details Defined in Data.Either.Validation Methods pure :: a -> Validation e a Source # (<*>) :: Validation e (a -> b) -> Validation e a -> Validation e b Source # liftA2 :: (a -> b -> c) -> Validation e a -> Validation e b -> Validation e c Source # (*>) :: Validation e a -> Validation e b -> Validation e b Source # (<*) :: Validation e a -> Validation e b -> Validation e a Source #
Functor (Validation e) Source # |
Instance details Defined in Data.Either.Validation Methods fmap :: (a -> b) -> Validation e a -> Validation e b Source # (<$) :: a -> Validation e b -> Validation e a Source #
Foldable (Validation e) Source # |

Instance details

Defined in Data.Either.Validation

Methods

fold :: Monoid m => Validation e m -> m Source #

foldMap :: Monoid m => (a -> m) -> Validation e a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Validation e a -> m Source #

foldr :: (a -> b -> b) -> b -> Validation e a -> b Source #

foldr' :: (a -> b -> b) -> b -> Validation e a -> b Source #

foldl :: (b -> a -> b) -> b -> Validation e a -> b Source #

foldl' :: (b -> a -> b) -> b -> Validation e a -> b Source #

foldr1 :: (a -> a -> a) -> Validation e a -> a Source #

foldl1 :: (a -> a -> a) -> Validation e a -> a Source #

toList :: Validation e a -> [a] Source #

null :: Validation e a -> Bool Source #

length :: Validation e a -> Int Source #

elem :: Eq a => a -> Validation e a -> Bool Source #

maximum :: Ord a => Validation e a -> a Source #

minimum :: Ord a => Validation e a -> a Source #

sum :: Num a => Validation e a -> a Source #

product :: Num a => Validation e a -> a Source #

Traversable (Validation e) Source # |
Instance details Defined in Data.Either.Validation Methods traverse :: Applicative f => (a -> f b) -> Validation e a -> f (Validation e b) Source # sequenceA :: Applicative f => Validation e (f a) -> f (Validation e a) Source # mapM :: Monad m => (a -> m b) -> Validation e a -> m (Validation e b) Source # sequence :: Monad m => Validation e (m a) -> m (Validation e a) Source #
Semigroup e => Alt (Validation e) Source # | For two errors, this instance reports both of them.
Instance details Defined in Data.Either.Validation Methods (<!>) :: Validation e a -> Validation e a -> Validation e a Source # some :: Applicative (Validation e) => Validation e a -> Validation e [a] Source # many :: Applicative (Validation e) => Validation e a -> Validation e [a] Source #
Semigroup e => Apply (Validation e) Source # |
Instance details Defined in Data.Either.Validation Methods (<.>) :: Validation e (a -> b) -> Validation e a -> Validation e b Source # (.>) :: Validation e a -> Validation e b -> Validation e b Source # (<.) :: Validation e a -> Validation e b -> Validation e a Source # liftF2 :: (a -> b -> c) -> Validation e a -> Validation e b -> Validation e c Source #
Monoid e => Monoid (Validation e a) Source # |
Instance details Defined in Data.Either.Validation Methods mempty :: Validation e a Source # mappend :: Validation e a -> Validation e a -> Validation e a Source # mconcat :: [Validation e a] -> Validation e a Source #
Semigroup e => Semigroup (Validation e a) Source # |
Instance details Defined in Data.Either.Validation Methods (<>) :: Validation e a -> Validation e a -> Validation e a Source # sconcat :: NonEmpty (Validation e a) -> Validation e a Source # stimes :: Integral b => b -> Validation e a -> Validation e a Source #
(Show e, Show a) => Show (Validation e a) Source # |
Instance details Defined in Data.Either.Validation Methods showsPrec :: Int -> Validation e a -> ShowS Source # show :: Validation e a -> String Source # showList :: [Validation e a] -> ShowS Source #
(Eq e, Eq a) => Eq (Validation e a) Source # |
Instance details Defined in Data.Either.Validation Methods (==) :: Validation e a -> Validation e a -> Bool Source # (/=) :: Validation e a -> Validation e a -> Bool Source #
(Ord e, Ord a) => Ord (Validation e a) Source # |

Instance details

Defined in Data.Either.Validation

Methods

compare :: Validation e a -> Validation e a -> Ordering Source #

(<) :: Validation e a -> Validation e a -> Bool Source #

(<=) :: Validation e a -> Validation e a -> Bool Source #

(>) :: Validation e a -> Validation e a -> Bool Source #

(>=) :: Validation e a -> Validation e a -> Bool Source #

max :: Validation e a -> Validation e a -> Validation e a Source #

min :: Validation e a -> Validation e a -> Validation e a Source #

_Success :: forall c a b p f. (Choice p, Applicative f) => p a (f b) -> p (Validation c a) (f (Validation c b)) Source #

_Failure :: forall a c b p f. (Choice p, Applicative f) => p a (f b) -> p (Validation a c) (f (Validation b c)) Source #

eitherToValidation :: Either e a -> Validation e a Source #

validationToEither :: Validation e a -> Either e a Source #

_Validation :: forall e a g b p f. (Profunctor p, Functor f) => p (Either e a) (f (Either g b)) -> p (Validation e a) (f (Validation g b)) Source #

`Validation` is isomorphic to `Either`

vap :: Semigroup m => Either m (a -> b) -> Either m a -> Either m b Source #

ealt :: Validation e a -> Validation e a -> Validation e a Source #

vapm :: Monoid m => Either m (a -> b) -> Either m a -> Either m b Source #

apm :: Monoid m => Validation m (a -> b) -> Validation m a -> Validation m b Source #