| 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 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 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