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