Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Data types similar to Data.Either
that are explicit about failure and success.
- data AccValidation err a
- = AccFailure err
- | AccSuccess a
- data Validation err a
- data ValidationT err m a = ValidationT {
- runValidationT :: m (Validation err a)
- data ValidationB m err a = ValidationB {
- runValidationB :: m (Validation err a)
- type Validation' err a = ValidationT err Identity a
- _Failure :: Validate f => Prism (f e1 a) (f e2 a) e1 e2
- _Success :: Validate f => Prism (f e a) (f e b) a b
- class Validate f where
- _Validation :: Iso (f e a) (f g b) (Validation e a) (Validation g b)
- _Validation' :: Iso (f e a) (f g b) (Validation' e a) (Validation' g b)
- _AccValidation :: Iso (f e a) (f g b) (AccValidation e a) (AccValidation g b)
- _Either :: Iso (f e a) (f g b) (Either e a) (Either g 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"]
AccFailure err | |
AccSuccess a |
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 => 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)) |
Typeable (* -> * -> *) AccValidation |
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"]
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) | |
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) | |
Typeable (* -> * -> *) Validation |
data ValidationT err m a Source
The transformer version of Validation
.
ValidationT | |
|
MonadTrans (ValidationT err) | |
Monad m => Monad (ValidationT err m) | |
Functor m => Functor (ValidationT err m) | |
Applicative m => Applicative (ValidationT err m) | |
Foldable m => Foldable (ValidationT err m) | |
Traversable m => Traversable (ValidationT err m) | |
(Functor m, Monad m) => Alt (ValidationT err m) | |
Apply m => Apply (ValidationT err m) | |
(Apply m, Monad m) => Bind (ValidationT err m) |
data ValidationB m err a Source
The bifunctor version of ValidationT
ValidationB | |
|
Traversable m => Bitraversable (ValidationB m) | |
Functor m => Bifunctor (ValidationB m) | |
Foldable m => Bifoldable (ValidationB m) | |
Functor f => Swapped (ValidationB f) | |
Monad m => Monad (ValidationB m err) | |
Functor m => Functor (ValidationB m err) | |
Applicative m => Applicative (ValidationB m err) | |
Foldable m => Foldable (ValidationB m err) | |
Traversable m => Traversable (ValidationB m err) | |
(Functor m, Monad m) => Alt (ValidationB m err) | |
Apply m => Apply (ValidationB m err) | |
(Apply m, Monad m) => Bind (ValidationB m err) |
type Validation' err a = ValidationT err Identity a Source
Prisms
Isomorphisms
Nothing
_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