| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Data.Validation
Contents
Description
Data types similar to Data.Either that are explicit about failure and success.
- data AccValidation err a
- = AccFailure err
- | AccSuccess 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
Data types
data AccValidation err a #
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 IntAccSuccess 8
>>>_Failure # ["f1"] <*> _Success # 7 :: AccValidation [String] IntAccFailure ["f1"]
>>>_Success # (+1) <*> _Failure # ["f2"] :: AccValidation [String] IntAccFailure ["f2"]
>>>_Failure # ["f1"] <*> _Failure # ["f2"] :: AccValidation [String] IntAccFailure ["f1","f2"]
Constructors
| AccFailure err | |
| AccSuccess a |
Instances
| Bifunctor AccValidation # | |
| Bitraversable AccValidation # | |
| Bifoldable AccValidation # | |
| Swapped AccValidation # | |
| Validate AccValidation # | |
| Functor (AccValidation err) # | |
| Semigroup err => Applicative (AccValidation err) # | |
| Foldable (AccValidation err) # | |
| Traversable (AccValidation err) # | |
| Alt (AccValidation err) # | |
| Semigroup err => Apply (AccValidation err) # | |
| (Eq a, Eq err) => Eq (AccValidation err a) # | |
| (Data a, Data err) => Data (AccValidation err a) # | |
| (Ord a, Ord err) => Ord (AccValidation err a) # | |
| (Show a, Show err) => Show (AccValidation err a) # | |
| Semigroup e => Semigroup (AccValidation e a) # | ((x <> y) <> z) == (x <> (y <> z :: AccValidation [String] Int)) |
| 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) |
Prisms
Isomorphisms
Methods
_AccValidation :: Iso (f e a) (f g b) (AccValidation e a) (AccValidation g b) #