Safe Haskell | Safe |
---|
Data types similar to Data.Either
that are explicit about failure and success.
- data AccValidation err a
- data Validation err a
- data ValidationT m err a = ValidationT {
- runValidationT :: m (Validation err a)
- type Validation' err a = ValidationT Identity err a
- class Validate f where
- isoAccValidationEither :: Iso (AccValidation e a) (AccValidation f b) (Either e a) (Either f b)
- isoValidationEither :: Iso (Validation e a) (Validation f b) (Either e a) (Either f b)
- isoAccValidationValidation :: Iso (AccValidation e a) (AccValidation f b) (Validation e a) (Validation f b)
- isoValidationTEither :: Iso (Validation' e a) (Validation' f b) (Either e a) (Either f b)
- isoAccValidationValidationT :: Iso (AccValidation e a) (AccValidation f b) (Validation' e a) (Validation' f b)
- isoValidationValidationT :: Iso (Validation e a) (Validation f b) (Validation' e a) (Validation' f b)
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"]
Typeable2 AccValidation | |
Bitraversable AccValidation | |
Bifunctor AccValidation | |
Bifoldable AccValidation | |
Swapped AccValidation | |
Validate AccValidation | |
Functor (AccValidation err) | |
Semigroup err => Applicative (AccValidation err) | |
Foldable (AccValidation err) | |
Traversable (AccValidation err) | |
(Semigroup err, Monoid err) => Alternative (AccValidation err) | |
Semigroup err => Alt (AccValidation err) | |
Semigroup err => Apply (AccValidation err) | |
(Eq err, Eq a) => Eq (AccValidation err a) | |
(Data err, Data a) => Data (AccValidation err a) | |
(Ord err, Ord a) => Ord (AccValidation err a) | |
(Show err, Show a) => Show (AccValidation err a) | |
Monoid e => Monoid (AccValidation e a) | ((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) | ((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"]
Typeable2 Validation | |
Bitraversable Validation | |
Bifunctor Validation | |
Bifoldable Validation | |
Swapped Validation | |
Validate Validation | |
Monad (Validation err) | |
Functor (Validation err) | |
Applicative (Validation err) | |
Foldable (Validation err) | |
Traversable (Validation err) | |
Monoid err => Alternative (Validation err) | |
Alt (Validation err) | |
Apply (Validation err) | |
Bind (Validation err) | |
(Eq err, Eq a) => Eq (Validation err a) | |
(Data err, Data a) => Data (Validation err a) | |
(Ord err, Ord a) => Ord (Validation err a) | |
(Show err, Show a) => Show (Validation err a) |
data ValidationT m err a Source
The transformer version of Validation
.
ValidationT | |
|
Traversable m => Bitraversable (ValidationT m) | |
Functor m => Bifunctor (ValidationT m) | |
Foldable m => Bifoldable (ValidationT m) | |
Functor f => Swapped (ValidationT f) | |
Monad m => Monad (ValidationT m err) | |
Functor m => Functor (ValidationT m err) | |
Applicative m => Applicative (ValidationT m err) | |
Foldable m => Foldable (ValidationT m err) | |
Traversable m => Traversable (ValidationT m err) | |
(Applicative m, Monad m, Monoid err) => Alternative (ValidationT m err) | |
(Functor m, Monad m) => Alt (ValidationT m err) | |
Apply m => Apply (ValidationT m err) | |
(Apply m, Monad m) => Bind (ValidationT m err) |
type Validation' err a = ValidationT Identity err aSource
Prisms
Isomorphisms
isoAccValidationEither :: Iso (AccValidation e a) (AccValidation f b) (Either e a) (Either f b)Source
isoValidationEither :: Iso (Validation e a) (Validation f b) (Either e a) (Either f b)Source
isoAccValidationValidation :: Iso (AccValidation e a) (AccValidation f b) (Validation e a) (Validation f b)Source
isoValidationTEither :: Iso (Validation' e a) (Validation' f b) (Either e a) (Either f b)Source
isoAccValidationValidationT :: Iso (AccValidation e a) (AccValidation f b) (Validation' e a) (Validation' f b)Source
isoValidationValidationT :: Iso (Validation e a) (Validation f b) (Validation' e a) (Validation' f b)Source