| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Data.Valor.Internal
Description
Guts of valor.
Synopsis
- newtype Valid a = Valid a
- unValid :: Valid a -> a
- newtype Valor i m e = Valor {}
- data Wrong e
- conW :: Semigroup e => Wrong e -> Wrong e -> Wrong e
- appW :: Wrong (a -> b) -> Wrong a -> Wrong b
- altW :: Wrong e -> Wrong e -> Wrong e
- accW :: Semigroup e => Wrong e -> Wrong e -> Wrong e
- valW :: Wrong e -> e
- wrong :: (e -> a) -> (e -> a) -> Wrong e -> a
- isInert :: Wrong e -> Bool
- isWrong :: Wrong e -> Bool
Documentation
Simple wrapper holding a Valid value that has successfully passed the
validation. It's not supposed to be mapped over, parsed, read, coerced etc.
(so as to not modify / spoil the Valid value). The only way to construct it
is by passing an input throug a validator using validateP or
validateM.
Constructors
| Valid a |
unValid :: Valid a -> a Source #
Extract a value from the Valid wrapper for further use / processing.
Valor (VALidatOR) is the centerpiece of this validation library. You
can think of it as a function from an input to a possible error.
Because Valor is essentially just an alias for a function of type
i -> m ( we can think of operations on Wrong e)Valor as operations
on the resulting Wrong once i has been applied.
Here's a useful table detailing the behavior of each operation on Wrong
(and consequently Valor):
con / <> | app / <*> | alt | acc | |
| | | | |
| | | | |
| | | | |
| | | | |
NOTE: You can not directly interact with Wrong as it is only used
internally in Valor.
Instances
| Monad m => Monad (Valor i m) Source # | Evaluates the "input" |
| Monad m => Functor (Valor i m) Source # | Evaluates the |
| Monad m => Applicative (Valor i m) Source # | Evaluates both |
| (Monad m, Semigroup e) => Semigroup (Valor i m e) Source # | Implemented using the |
| (Monad m, Monoid e) => Monoid (Valor i m e) Source # | |
The internal data type used to accumulate errors and keep track of the error state (if there was an actual error or not).
Instances
| Functor Wrong Source # | Just a simple |
| Applicative Wrong Source # |
|
| Eq e => Eq (Wrong e) Source # | |
| Semigroup e => Semigroup (Wrong e) Source # |
|
| Monoid e => Monoid (Wrong e) Source # | |