validationt-0.2.1.0: Straightforward validation monad.

Safe HaskellNone
LanguageHaskell2010

Control.Monad.Validation

Synopsis

Documentation

newtype ValidationT e m a Source #

Collects all throwed "warnings" throwed through StateT and "errors" throwed through ExceptT to single value using Monoid FIXME: give more instances like HReaderT and MonadBaseControl/MonadMask

Constructors

ValidationT 

Fields

Instances
MonadBase b m => MonadBase b (ValidationT e m) Source # 
Instance details

Defined in Control.Monad.Validation

Methods

liftBase :: b α -> ValidationT e m α #

MonadTrans (ValidationT e) Source # 
Instance details

Defined in Control.Monad.Validation

Methods

lift :: Monad m => m a -> ValidationT e m a #

LiftLocal (ValidationT e) Source # 
Instance details

Defined in Control.Monad.Validation

Methods

liftLocal :: Monad m => m r -> (forall a. Local r m a) -> forall a. Local r (ValidationT e m) a #

Monad m => Monad (ValidationT e m) Source # 
Instance details

Defined in Control.Monad.Validation

Methods

(>>=) :: ValidationT e m a -> (a -> ValidationT e m b) -> ValidationT e m b #

(>>) :: ValidationT e m a -> ValidationT e m b -> ValidationT e m b #

return :: a -> ValidationT e m a #

fail :: String -> ValidationT e m a #

Functor m => Functor (ValidationT e m) Source # 
Instance details

Defined in Control.Monad.Validation

Methods

fmap :: (a -> b) -> ValidationT e m a -> ValidationT e m b #

(<$) :: a -> ValidationT e m b -> ValidationT e m a #

Monad m => Applicative (ValidationT e m) Source # 
Instance details

Defined in Control.Monad.Validation

Methods

pure :: a -> ValidationT e m a #

(<*>) :: ValidationT e m (a -> b) -> ValidationT e m a -> ValidationT e m b #

liftA2 :: (a -> b -> c) -> ValidationT e m a -> ValidationT e m b -> ValidationT e m c #

(*>) :: ValidationT e m a -> ValidationT e m b -> ValidationT e m b #

(<*) :: ValidationT e m a -> ValidationT e m b -> ValidationT e m a #

MonadThrow m => MonadThrow (ValidationT e m) Source # 
Instance details

Defined in Control.Monad.Validation

Methods

throwM :: Exception e0 => e0 -> ValidationT e m a #

MonadCatch m => MonadCatch (ValidationT e m) Source # 
Instance details

Defined in Control.Monad.Validation

Methods

catch :: Exception e0 => ValidationT e m a -> (e0 -> ValidationT e m a) -> ValidationT e m a #

newtype MonoidMap k v Source #

Map with Monoid instance which mappend its values

Constructors

MonoidMap (Map k v) 
Instances
(Eq k, Eq v) => Eq (MonoidMap k v) Source # 
Instance details

Defined in Control.Monad.Validation

Methods

(==) :: MonoidMap k v -> MonoidMap k v -> Bool #

(/=) :: MonoidMap k v -> MonoidMap k v -> Bool #

(Ord k, Ord v) => Ord (MonoidMap k v) Source # 
Instance details

Defined in Control.Monad.Validation

Methods

compare :: MonoidMap k v -> MonoidMap k v -> Ordering #

(<) :: MonoidMap k v -> MonoidMap k v -> Bool #

(<=) :: MonoidMap k v -> MonoidMap k v -> Bool #

(>) :: MonoidMap k v -> MonoidMap k v -> Bool #

(>=) :: MonoidMap k v -> MonoidMap k v -> Bool #

max :: MonoidMap k v -> MonoidMap k v -> MonoidMap k v #

min :: MonoidMap k v -> MonoidMap k v -> MonoidMap k v #

(Show k, Show v) => Show (MonoidMap k v) Source # 
Instance details

Defined in Control.Monad.Validation

Methods

showsPrec :: Int -> MonoidMap k v -> ShowS #

show :: MonoidMap k v -> String #

showList :: [MonoidMap k v] -> ShowS #

(Ord k, Semigroup v) => Semigroup (MonoidMap k v) Source # 
Instance details

Defined in Control.Monad.Validation

Methods

(<>) :: MonoidMap k v -> MonoidMap k v -> MonoidMap k v #

sconcat :: NonEmpty (MonoidMap k v) -> MonoidMap k v #

stimes :: Integral b => b -> MonoidMap k v -> MonoidMap k v #

(Ord k, Monoid v) => Monoid (MonoidMap k v) Source # 
Instance details

Defined in Control.Monad.Validation

Methods

mempty :: MonoidMap k v #

mappend :: MonoidMap k v -> MonoidMap k v -> MonoidMap k v #

mconcat :: [MonoidMap k v] -> MonoidMap k v #

(Ord k, Arbitrary k, Arbitrary v) => Arbitrary (MonoidMap k v) Source # 
Instance details

Defined in Control.Monad.Validation

Methods

arbitrary :: Gen (MonoidMap k v) #

shrink :: MonoidMap k v -> [MonoidMap k v] #

(ToJSON k, ToJSON v) => ToJSON (MonoidMap k v) Source # 
Instance details

Defined in Control.Monad.Validation

(Ord k, FromJSON k, FromJSON v) => FromJSON (MonoidMap k v) Source # 
Instance details

Defined in Control.Monad.Validation

Ord k => Ixed (MonoidMap k v) Source # 
Instance details

Defined in Control.Monad.Validation

Methods

ix :: Index (MonoidMap k v) -> Traversal' (MonoidMap k v) (IxValue (MonoidMap k v)) #

Ord k => At (MonoidMap k v) Source # 
Instance details

Defined in Control.Monad.Validation

Methods

at :: Index (MonoidMap k v) -> Lens' (MonoidMap k v) (Maybe (IxValue (MonoidMap k v))) #

type Index (MonoidMap k v) Source # 
Instance details

Defined in Control.Monad.Validation

type Index (MonoidMap k v) = k
type IxValue (MonoidMap k v) Source # 
Instance details

Defined in Control.Monad.Validation

type IxValue (MonoidMap k v) = v

_MonoidMap :: forall k v k v. Iso (MonoidMap k v) (MonoidMap k v) (Map k v) (Map k v) Source #

mmAppend :: (Ord k, Semigroup v) => MonoidMap k v -> MonoidMap k v -> MonoidMap k v Source #

mmSingleton :: (Eq v, Monoid v, Ord k) => k -> v -> MonoidMap k v Source #

Convenient for vZoom as first artument. Will prevent generation of map with mempty values

setMempty :: Monoid s => ASetter' s a -> a -> s Source #

Set given value to mempty

memptyWrap :: (Eq a, Monoid a) => b -> (a -> b) -> a -> b Source #

neConcat :: (Foldable f, Eq (f a), Monoid a, Monoid (f a)) => (a -> a -> a) -> f a -> Maybe a Source #

If given container is not mempty, then use given function to append all its elements and return Just result

runValidationT :: (Monoid e, Monad m) => ValidationT e m a -> m (e, Maybe a) Source #

Returns mempty instead of error if no warnings was occured. So, your error should have Eq instance to detect that any error was occured. Returns Nothing for second element of tuple if compuration was interruped by vError

runValidationTEither :: (Monoid e, Eq e, Monad m) => ValidationT e m a -> m (Either e a) Source #

handleValidationT :: (Monoid e, Monad m, Eq e) => (e -> m a) -> ValidationT e m a -> m a Source #

vError :: Monad m => e -> ValidationT e m a Source #

Stops further execution of validation

vWarning :: (Monad m, Monoid e) => e -> ValidationT e m () Source #

Does not stop further execution, append warning to

vErrorL :: (Monad m, Monoid e) => ASetter' e a -> a -> ValidationT e m x Source #

vWarningL :: (Monad m, Monoid e) => ASetter' e a -> a -> ValidationT e m () Source #

vZoom :: (Monad m, Monoid a, Monoid b) => (a -> b) -> ValidationT a m x -> ValidationT b m x Source #

vZoomL :: (Monad m, Monoid a, Monoid b) => ASetter' b a -> ValidationT a m x -> ValidationT b m x Source #