validationt-0.2.0.0: Straightforward validation monad. Convenient solution for validating web forms and APIs.

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 # 

Methods

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

MonadTrans (ValidationT e) Source # 

Methods

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

LiftLocal (ValidationT e) Source # 

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 # 

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 # 

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 # 

Methods

pure :: a -> ValidationT e m a #

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

(*>) :: 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 # 

Methods

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

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

Methods

catch :: Exception e => ValidationT e m a -> (e -> 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 v, Eq k) => Eq (MonoidMap k v) Source # 

Methods

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

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

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

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 v, Show k) => Show (MonoidMap k v) Source # 

Methods

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

show :: MonoidMap k v -> String #

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

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

Methods

mempty :: MonoidMap k v #

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

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

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

Methods

arbitrary :: Gen (MonoidMap k v) #

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

(ToJSON k, ToJSON v) => ToJSON (MonoidMap k v) Source # 
(Ord k, FromJSON k, FromJSON v) => FromJSON (MonoidMap k v) Source # 
Ord k => Ixed (MonoidMap k v) Source # 

Methods

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

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

Methods

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

type Index (MonoidMap k v) Source # 
type Index (MonoidMap k v) = k
type IxValue (MonoidMap k v) Source # 
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 #

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 #