| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
Control.Monad.Validate.Class
Documentation
class (Monad m, Semigroup e) => MonadValidate e m | m -> e where Source #
The class of validation monads, intended to be used to validate data structures while collecting
errors along the way. In a sense, MonadValidate is like a combination of
MonadError and MonadWriter, but it isn’t
entirely like either. The two essential differences are:
- Unlike 
throwError, raising an error usingrefutedoes not always abort the entire computation—it may only abort a local part of it. - Unlike 
tell, raising an error usingdisputestill causes the computation to globally fail, it just doesn’t affect local execution. 
For a more thorough explanation, with examples, see the documentation for
ValidateT. 
Minimal complete definition
Nothing
Methods
Raises a fatal validation error. Aborts the current branch of the validation (i.e. does not return).
>>>runValidate(refute["boom"]>>refute["bang"])Left["boom"]
Raises a non-fatal validation error. The overall validation fails, and the error is recorded, but validation continues in an attempt to try and discover more errors.
>>>runValidate(dispute["boom"]>>dispute["bang"])Left["boom", "bang"]
tolerate :: m a -> m (Maybe a) Source #
 behaves like tolerate mm, except that any fatal errors raised by refute are altered
 to non-fatal errors that return Nothing. This allows m’s result to be used for further
 validation if it succeeds without preventing further validation from occurring upon failure.
>>>runValidate(tolerate(refute["boom"])>>refute["bang"])Left["boom", "bang"]
Since: 1.1.0.0
refute :: (MonadTrans t, MonadValidate e m', m ~ t m') => e -> m a Source #
Raises a fatal validation error. Aborts the current branch of the validation (i.e. does not return).
>>>runValidate(refute["boom"]>>refute["bang"])Left["boom"]
dispute :: (MonadTrans t, MonadValidate e m', m ~ t m') => e -> m () Source #
Raises a non-fatal validation error. The overall validation fails, and the error is recorded, but validation continues in an attempt to try and discover more errors.
>>>runValidate(dispute["boom"]>>dispute["bang"])Left["boom", "bang"]
tolerate :: (MonadTransControl t, MonadValidate e m', m ~ t m') => m a -> m (Maybe a) Source #
 behaves like tolerate mm, except that any fatal errors raised by refute are altered
 to non-fatal errors that return Nothing. This allows m’s result to be used for further
 validation if it succeeds without preventing further validation from occurring upon failure.
>>>runValidate(tolerate(refute["boom"])>>refute["bang"])Left["boom", "bang"]
Since: 1.1.0.0
Instances
| MonadValidate e m => MonadValidate e (MaybeT m) Source # | |
| (MonadValidate e m, Monoid w) => MonadValidate e (WriterT w m) Source # | |
| (MonadValidate e m, Monoid w) => MonadValidate e (WriterT w m) Source # | |
| (MonadValidate e m, Monoid w) => MonadValidate e (WriterT w m) Source # | |
| MonadValidate e m => MonadValidate e (StateT s m) Source # | |
| MonadValidate e m => MonadValidate e (StateT s m) Source # | |
| MonadValidate e m => MonadValidate e (ReaderT r m) Source # | |
| MonadValidate e m => MonadValidate e (IdentityT m) Source # | |
| MonadValidate e m => MonadValidate e (ExceptT a m) Source # | |
| (Monad m, Semigroup e) => MonadValidate e (ValidateT e m) Source # | |
| (MonadValidate e m, Monoid w) => MonadValidate e (RWST r w s m) Source # | |
| (MonadValidate e m, Monoid w) => MonadValidate e (RWST r w s m) Source # | |
| (MonadValidate e m, Monoid w) => MonadValidate e (RWST r w s m) Source # | |