-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Input validation combinator library
--   
--   A small Haskell combinator library that provides a simple way of
--   validating user provided data structures.
@package validate-input
@version 0.4.0.0

module Data.Validator

-- | The validation monad
type ValidationM e = ValidationT e Identity

-- | The validation monad transformer
data ValidationT e m a

-- | A validation rule. Combine using <tt>(<a>&gt;=&gt;</a>)</tt> or
--   <tt>(<a>&lt;=&lt;</a>)</tt>
type ValidationRule e a = ValidationRuleT e Identity a

-- | A validation rule. Combine using <tt>(<a>&gt;=&gt;</a>)</tt> or
--   <tt>(<a>&lt;=&lt;</a>)</tt>
type ValidationRuleT e m a = TransValidationRuleT e m a a

-- | A transforming validation rule. Combine using
--   <tt>(<a>&gt;=&gt;</a>)</tt> or <tt>(<a>&lt;=&lt;</a>)</tt>
type TransValidationRule e a b = TransValidationRuleT e Identity a b

-- | A transforming validation rule. Combine using
--   <tt>(<a>&gt;=&gt;</a>)</tt> or <tt>(<a>&lt;=&lt;</a>)</tt>
type TransValidationRuleT e m a b = a -> ValidationT e m b

-- | Run a validation on a type <tt>a</tt>
runValidator :: TransValidationRule e a b -> a -> Either e b

-- | Run a validation on a type <tt>a</tt>
runValidatorT :: Monad m => TransValidationRuleT e m a b -> a -> m (Either e b)

-- | Left-to-right Kleisli composition of monads.
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
infixr 1 >=>

-- | Right-to-left Kleisli composition of monads.
--   <tt>(<a>&gt;=&gt;</a>)</tt>, with the arguments flipped.
--   
--   Note how this operator resembles function composition
--   <tt>(<a>.</a>)</tt>:
--   
--   <pre>
--   (.)   ::            (b -&gt;   c) -&gt; (a -&gt;   b) -&gt; a -&gt;   c
--   (&lt;=&lt;) :: Monad m =&gt; (b -&gt; m c) -&gt; (a -&gt; m b) -&gt; a -&gt; m c
--   </pre>
(<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
infixr 1 <=<

-- | Check that the value is at least N elements long
minLength :: (Monad m, HasLength a) => Int64 -> e -> ValidationRuleT e m a

-- | Check that the value is at maxium N elements long
maxLength :: (Monad m, HasLength a) => Int64 -> e -> ValidationRuleT e m a

-- | Check that the value's length is between N and M
lengthBetween :: (Monad m, HasLength a) => Int64 -> Int64 -> e -> ValidationRuleT e m a

-- | Specialized minLength with N = 1
notEmpty :: (Monad m, HasLength a) => e -> ValidationRuleT e m a

-- | Check that a value is larger than N
largerThan :: (Monad m, Ord a) => a -> e -> ValidationRuleT e m a

-- | Check that a value is smaller than N
smallerThan :: (Monad m, Ord a) => a -> e -> ValidationRuleT e m a

-- | Check that a value is between M and N
valueBetween :: (Monad m, Ord a) => a -> a -> e -> ValidationRuleT e m a

-- | Checks that a value matches a regular expression
matchesRegex :: (ConvertibleStrings SBS a, ConvertibleStrings a SBS, Monad m) => Regex -> e -> ValidationRuleT e m a

-- | Check that a value conforms a predicate
conformsPred :: Monad m => (a -> Bool) -> e -> ValidationRuleT e m a

-- | Check that a value conforms a predicate
conformsPredM :: Monad m => (a -> m Bool) -> e -> ValidationRuleT e m a

-- | Check that an optional value is actually set to 'Just a'
requiredValue :: Monad m => e -> TransValidationRuleT e m (Maybe a) a

-- | Check that a list is not empty
nonEmptyList :: Monad m => e -> TransValidationRuleT e m [a] (NonEmpty a)

-- | Do some check returning <a>Nothing</a> if the value is invalid and
--   'Just a' otherwise.
conformsPredTrans :: Monad m => (a -> Maybe b) -> e -> TransValidationRuleT e m a b

-- | Do some check returning <a>Nothing</a> if the value is invalid and
--   'Just a' otherwise.
conformsPredTransM :: Monad m => (a -> m (Maybe b)) -> e -> TransValidationRuleT e m a b

-- | All types that have a length, eg. <a>String</a>, '[a]', 'Vector a',
--   etc.
class HasLength a
getLength :: HasLength a => a -> Int64
class ConvertibleStrings a b
convertString :: ConvertibleStrings a b => a -> b

-- | 64-bit signed integer type
data Int64 :: *

-- | A QuasiQuoter for regular expressions that does a compile time check.
re :: QuasiQuoter

-- | Returns a QuasiQuoter like <a>re</a>, but with given PCRE options.
mkRegexQQ :: [PCREOption] -> QuasiQuoter

-- | An abstract pointer to a compiled PCRE Regex structure The structure
--   allocated by the PCRE library will be deallocated automatically by the
--   Haskell storage manager.
data Regex :: *
instance Control.Monad.Trans.Class.MonadTrans (Data.Validator.ValidationT e)
instance (GHC.Base.Monoid e, GHC.Base.Monad m) => GHC.Base.MonadPlus (Data.Validator.ValidationT e m)
instance (GHC.Base.Monoid e, GHC.Base.Monad m) => GHC.Base.Alternative (Data.Validator.ValidationT e m)
instance GHC.Base.Monad m => GHC.Base.Applicative (Data.Validator.ValidationT e m)
instance GHC.Base.Monad m => GHC.Base.Functor (Data.Validator.ValidationT e m)
instance GHC.Base.Monad m => GHC.Base.Monad (Data.Validator.ValidationT e m)
instance Data.Validator.HasLength [a]
instance Data.Validator.HasLength Data.Text.Internal.Text
instance Data.Validator.HasLength Data.Text.Internal.Lazy.Text
instance Data.Validator.HasLength Data.ByteString.Internal.ByteString
instance Data.Validator.HasLength Data.ByteString.Lazy.Internal.ByteString
