either-4.4.1.1: An either monad transformer

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

Data.Either.Validation

Description

Monoidal `Validation` sibling to `Either`.

Synopsis

- data Validation e a
  - = Failure e
  - | Success a
- _Success :: Prism (Validation c a) (Validation c b) a b
- _Failure :: Prism (Validation a c) (Validation b c) a b
- eitherToValidation :: Either e a -> Validation e a
- validationToEither :: Validation e a -> Either e a
- _Validation :: Iso (Validation e a) (Validation g b) (Either e a) (Either g b)

# Documentation

data Validation e a Source #

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

Constructors

Failure e |
Success a |

Instances

Bifunctor Validation Source # |
Methods bimap :: (a -> b) -> (c -> d) -> Validation a c -> Validation b d # first :: (a -> b) -> Validation a c -> Validation b c # second :: (b -> c) -> Validation a b -> Validation a c #
Bitraversable Validation Source # |
Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Validation a b -> f (Validation c d) #
Bifoldable Validation Source # |
Methods bifold :: Monoid m => Validation m m -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Validation a b -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Validation a b -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Validation a b -> c #
Functor (Validation e) Source # |
Methods fmap :: (a -> b) -> Validation e a -> Validation e b # (<$) :: a -> Validation e b -> Validation e a #
Semigroup e => Applicative (Validation e) Source # |
Methods pure :: a -> Validation e a # (<*>) :: Validation e (a -> b) -> Validation e a -> Validation e b # (*>) :: Validation e a -> Validation e b -> Validation e b # (<*) :: Validation e a -> Validation e b -> Validation e a #
Foldable (Validation e) Source # |

Methods

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

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

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

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

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

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

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

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

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

null :: Validation e a -> Bool #

length :: Validation e a -> Int #

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

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

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

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

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

Traversable (Validation e) Source # |
Methods traverse :: Applicative f => (a -> f b) -> Validation e a -> f (Validation e b) # sequenceA :: Applicative f => Validation e (f a) -> f (Validation e a) # mapM :: Monad m => (a -> m b) -> Validation e a -> m (Validation e b) # sequence :: Monad m => Validation e (m a) -> m (Validation e a) #
(Semigroup e, Monoid e) => Alternative (Validation e) Source # |
Methods empty :: Validation e a # (<|>) :: Validation e a -> Validation e a -> Validation e a # some :: Validation e a -> Validation e [a] # many :: Validation e a -> Validation e [a] #
Alt (Validation e) Source # |
Methods (<!>) :: Validation e a -> Validation e a -> Validation e a # some :: Applicative (Validation e) => Validation e a -> Validation e [a] # many :: Applicative (Validation e) => Validation e a -> Validation e [a] #
(Eq a, Eq e) => Eq (Validation e a) Source # |
Methods (==) :: Validation e a -> Validation e a -> Bool # (/=) :: Validation e a -> Validation e a -> Bool #
(Ord a, Ord e) => Ord (Validation e a) Source # |
Methods compare :: Validation e a -> Validation e a -> Ordering # (<) :: Validation e a -> Validation e a -> Bool # (<=) :: Validation e a -> Validation e a -> Bool # (>) :: Validation e a -> Validation e a -> Bool # (>=) :: Validation e a -> Validation e a -> Bool # max :: Validation e a -> Validation e a -> Validation e a # min :: Validation e a -> Validation e a -> Validation e a #
(Show a, Show e) => Show (Validation e a) Source # |
Methods showsPrec :: Int -> Validation e a -> ShowS # show :: Validation e a -> String # showList :: [Validation e a] -> ShowS #
Semigroup e => Semigroup (Validation e a) Source # |
Methods (<>) :: Validation e a -> Validation e a -> Validation e a # sconcat :: NonEmpty (Validation e a) -> Validation e a # stimes :: Integral b => b -> Validation e a -> Validation e a #
Monoid e => Monoid (Validation e a) Source # |
Methods mempty :: Validation e a # mappend :: Validation e a -> Validation e a -> Validation e a # mconcat :: [Validation e a] -> Validation e a #

_Success :: Prism (Validation c a) (Validation c b) a b Source #

_Failure :: Prism (Validation a c) (Validation b c) a b Source #

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

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

_Validation :: Iso (Validation e a) (Validation g b) (Either e a) (Either g b) Source #

`Validation` is isomorphic to `Either`