h$OM      !"#$%&'()*+,-./0123456789:;<=>?@AB Safe-Inferred?CDEFGHIJSafeeKSafe38 validaLike L8, but accumulates failures upon applicative composition.valida.Represents a validation failure with an error.valida)This behaves similar to the L" semigroup. i.e Returns the first . But also accumulates s.ExamplesSuccess 1 <> Success 2 Success 1Failure "error" <> Success 1 Success 1Success 2 <> Failure "error" Success 2$Failure ["err1"] <> Failure ["err2"]Failure ["err1","err2"]Wvalida pureR is a  value.(<*>)X behaves similar to L/, but accumulates failures instead of stopping.Examplespure 2 :: Validation String Int Success 2Success (+1) <*> Success 4 Success 5 Success (+1) <*> Failure "error"Failure "error"%Failure ["err1"] <*> Failure ["err2"]Failure ["err1","err2"]Yvalida fmapZ maps given function over a  value, does nothing on  value.Examplesfmap (+1) (Success 2) Success 3fmap (+1) (Failure "error")Failure "error"Safe1 valida Convert a  to an L.Given, Validation a b- Failure a is converted to Left a. Success b is converted to Right b.Examples0toEither (Success 'c' :: Validation String Char) Right 'c',toEither (Failure 42 :: Validation Int Char)Left 42valida Convert a L to an .Given,  Either e a-Left e is converted to  Failure e.Right a is converted to  Success a.Examples,fromEither (Right 'c' :: Either String Char) Success 'c''fromEither (Left 42 :: Either Int Char) Failure 42valida$Return True if the given value is a -value, False otherwise.valida$Return True if the given value is a -value, False otherwise. validaReturn the contents of a $-value or a default value otherwise.Examples0fromFailure 0 (Success 48 :: Validation Int Int)00fromFailure 0 (Failure 27 :: Validation Int Int)27 validaReturn the contents of a $-value or a default value otherwise.Examples0fromSuccess 0 (Success 48 :: Validation Int Int)480fromSuccess 0 (Failure 27 :: Validation Int Int)0 validaExtracts from a list of  all the  values, in order.Examplesfailures [Success 48, Failure "err1", Failure "err2", Success 2, Failure "err3"]["err1","err2","err3"]failures ([Success 1, Success 2, Success 3] :: [Validation String Int])[] validaExtracts from a list of $ all the Success elements, in order.Examplessuccesses [Success 1, Failure "err1", Failure "err2", Success 2, Failure "err3"][1,2]successes ([Failure "err1", Failure "err2", Failure "err3"] :: [Validation String Int])[] valida+Partitions a list of Either into two lists.All the Left elements are extracted, in order, to the first component of the output. Similarly the Right elements are extracted to the second component of the output. partitionValidations xs = (  xs,   xs)ExamplespartitionValidations [Success 1, Failure "err1", Failure "err2", Success 2, Failure "err3"](["err1","err2","err3"],[1,2])  Safe8> \validaAn applicative validator. Validates a predicate on an input when run and returns the  result.The type can be understood as- Validator e inp a ^ ^ ^------ The output type on successful validation | | Error type |-- The input on which validation is run Validators are run using the  runValidator! function. The result is of type Validation e a7, corresponding to the type params of the same name on .Note: All the primitive combinators (and derivative combinators) use the same type for inp and a. In those cases - upon successful validation, the input itself, wrapped in , is returned.[valida lmap\ runs given function on  input before applying it to the validator function. This is similar to the   type.rmap] is the same as Z.Examples8runValidator (lmap fst (failureIf (==2) "IsTwo")) (3, 2) Success 38runValidator (lmap snd (failureIf (==2) "IsTwo")) (3, 2)Failure ("IsTwo" :| [])4runValidator (rmap (+1) (failureIf (==2) "IsTwo")) 3Failure ("IsTwo" :| [])^valida memptyU. is a validator that always succeeds and uses unit as output type.Examples3runValidator (mempty :: Validator String Int ()) 42 Success ()_valida (<>)` builds a validator that succeeds/ only if both of the given validators succeed.  Left-most& failure is returned, other validator  is not used* if one fails. If all validators succeed,  right-most success is returned.Examples let v1 = failureIf (==2) "IsTwo" let v2 = failureIf even "IsEven"runValidator (v1 <> v2) 5 Success 5runValidator (v1 <> v2) 4Failure ("IsEven" :| [])runValidator (v1 <> v2) 2Failure ("IsTwo" :| [])avalida pureR creates a + that always yields given value wrapped in , ignoring its input.(<*>)X# runs 2 validators to obtain the 2  results and combines them with X. This can be understood as- (Validator ff) <*> (Validator v) = Validator (\inp -> ff inp <*> v inp) i.e Run ff and v on the input, and compose the  results with X.ExamplesrunValidator (pure 5) 42 Success 5runValidator (const <$> failureIf (==2) "IsTwo" <*> failureIf even "IsEven") 5 Success 5runValidator (const <$> failureIf (==2) "IsTwo" <*> failureIf even "IsEven") 4Failure ("IsEven" :| [])runValidator (const <$> failureIf (==2) "IsTwo" <*> failureIf even "IsEven") 2Failure ("IsTwo" :| ["IsEven"])bvalida fmapZ maps given function over the  result by re-using Z on it.Examples4runValidator (fmap (+1) (failureIf (==2) "IsTwo")) 3 Success 44runValidator (fmap (+1) (failureIf (==2) "IsTwo")) 2Failure ("IsTwo" :| [])c5Combinators and utilities for building and combining s(c) TotallyNotChase, 2021MITtotallynotchase42@gmail.comStablePortableSafeA3.validaBuild a rule that fails with given error if the given predicate succeeds. failureIf predc =  (d . predc)Examples*runValidator (failureIf (>0) "Positive") 5Failure ("Positive" :| [])*runValidator (failureIf (>0) "Positive") 0 Success 0-runValidator (failureIf (>0) "Positive") (-1) Success (-1)validaBuild a rule that fails with given error #unless the given predicate succeeds. failureUnless predc =  (d . predc)Examples1runValidator (failureUnless (>0) "NonPositive") 5 Success 51runValidator (failureUnless (>0) "NonPositive") 0Failure ("NonPositive" :| [])4runValidator (failureUnless (>0) "NonPositive") (-1)Failure ("NonPositive" :| [])validaLike  but uses Unit as the  error type. failureIf' predc =  (d . predc) label (N# (err :| [])) (failureIf' predc) =  predc errExamples runValidator (failureIf' (>0)) 5 Failure () runValidator (failureIf' (>0)) 0 Success 0#runValidator (failureIf' (>0)) (-1) Success (-1)validaLike  but uses Unit as the  error type. failureUnless' predc =  (d . predc) label (N' (err :| [])) (failureUnless' predc) =  predc errExamples$runValidator (failureUnless' (>0)) 5 Success 5$runValidator (failureUnless' (>0)) 0 Failure ()'runValidator (failureUnless' (>0)) (-1) Failure ()valida!Build an equality rule for value.  mustBe x =  (==x)valida"Build an equality rule for length.  ofLength x =  ((==x) . e)valida(Build a minimum length (inclusive) rule. minLengthOf x =  ((>=n) . e)valida(Build a maximum length (inclusive) rule. maxLengthOf n =  ((<=n) . e)valida(Build a minimum length (inclusive) rule. lengthAbove x =  (x + 1) lengthAbove x =  ((>n) . e)valida(Build a maximum length (inclusive) rule. lengthBelow x =  (x - 1) lengthBelow x =  ((=x)valida'Build a maximum value (inclusive) rule. maxValueOf x =  (<=x)valida'Build a minimum value (exclusive) rule. valueAbove x =  (x + 1) valueAbove x =  (>x)valida'Build a maximum value (exclusive) rule. valueBelow x =  (x - 1) valueBelow x =  ( m <= x && x <= n)!valida Build an h rule. onlyContains x =  (h x)"valida Build an i rule. atleastContains x =  (i x)#valida Build an j rule. mustContain x = " (==x) mustContain x =  (j x)$validaLike  but uses Unit as the  error type.%validaLike  but uses Unit as the  error type.&validaLike  but uses Unit as the  error type.'validaLike  but uses Unit as the  error type.(validaLike  but uses Unit as the  error type.)validaLike  but uses Unit as the  error type.*validaLike  but uses Unit as the  error type.+validaLike  but uses Unit as the  error type.,validaLike  but uses Unit as the  error type.-validaLike  but uses Unit as the  error type..validaLike  but uses Unit as the  error type./validaLike  but uses Unit as the  error type.0validaLike   but uses Unit as the  error type.1validaLike ! but uses Unit as the  error type.2validaLike " but uses Unit as the  error type.3validaLike # but uses Unit as the  error type.4validaBuild a validator that succeeds if given validator fails and vice versa.Note": This will set the output of the  to be the same as its input, thereby ignoring the original output.Examples0) "Positive")runValidator vald 5 Success 5runValidator vald 0Failure "NonPositive"runValidator vald (-1)Failure "NonPositive"5validaLike 4 but uses Unit as the  error type.6validaA synonym for 7:. Satisfies associativity law and hence forms a semigroup.7validaBuild a validator that succeeds if either8 of the given validators succeed. The first (left-most)  is returned. If both fail, the errors are combined. Other validator  is not used if first one succeeds. vald1 `orElse` (vald2 `orElse` vald3) = (vald1 `orElse` vald2) `orElse` vald3 8 e `orElse` vald = vald vald `orElse` 8 e = valdExampleslet vald = failureIf (>0) "Positive" `orElse` failureIf even "Even"runValidator vald 5 Success 5runValidator vald 4 Failure ("Positive" :| ["Even"])runValidator vald 0 Success 0runValidator vald (-1) Success (-1)8validaA  that always fails with supplied error. This is the identity of 7 (i.e 6). failV `7 ` vald = vald vald `7` failV = valdExamples3runValidator (failV :: Validator String Int Int) 42 Failure ""9validaBuild a validator that  only succeeds if both& of the given validators succeed. The first (left-most)* failure is yielded. If both succeed, the  right-most % result is returned. Other validator  is not used if first one fails.1This is the same as the semigroup operation (i.e `) on . vald1 `andAlso` (vald2 `andAlso` vald3) = (vald1 `andAlso` vald2) `andAlso` vald3 U `andAlso` vald = vald vald `andAlso` U = valdExampleslet vald = failureIf (>0) "Positive" `andAlso` failureIf even "Even"runValidator vald 5Failure ("Positive" :| [])runValidator vald (-2)Failure ("Even" :| [])runValidator vald (-1) Success (-1):validaBuild a validator that succeeds if any of the given validators succeed. If all fail, the errors are combined. The first (left-most) * is returned. If all fail, the errors are combined. Remaining validators  are not used once one succeeds.  satisfyAny = k 7  satisfyAny = l 7  satisfyAny = m 7 8  satisfyAny = n 7 8;validaBuild a validator that  only succeeds if all& of the given validators succeed. The first (left-most)) failure is yielded. If all succeed, the  right-most * result is returned. Remaining validators  are not used once one fails.  satisfyAll =    satisfyAll = k 9  satisfyAll = l 9  satisfyAll = m 9 U  satisfyAll = n 9 U<valida=Build a validator that runs given validator only if input is o.Yields  when input is p.Examples:runValidator (optionally (failureIf even "Even")) (Just 5)Success (Just 5):runValidator (optionally (failureIf even "Even")) (Just 6)Failure ("Even" :| [])9runValidator (optionally (failureIf even "Even")) NothingSuccess Nothing=valida=Build a validator that runs given validator only if input is o!. Yields default value otherwise.Yields  when input is p', and wrapped around the default value. vald `withDefault` deflt =   deflt q < valdExamples=runValidator (failureIf even "Even" `withDefault` 0) (Just 5)Success (Just 5)=runValidator (failureIf even "Even" `withDefault` 0) (Just 6)Failure ("Even" :| [])>valida An alias to \ specialized to .>! allows a validator taking input b to work with input a, provided a function of type: a -> b.The new  first runs the selector on its input to obtain the validation target. Then, it runs the predicate on the target.If validation is successful, the the *original* output is put into the  result.ExamplesThis is the primary functions to build validators for product types. To validate a pair, the most basic product type, such that the first element is a non empty string, and the second element is a number greater than 9, you can use:let pairValidator = (,) <$> verify (notEmpty "EmptyString") fst <*> verify (failureIf (<10) "LessThan10") snd4You can then run the validator on your input, using :&runValidator pairValidator ("foo", 12)Success ("foo",12)#runValidator pairValidator ("", 12)Failure ("EmptyString" :| [])%runValidator pairValidator ("foo", 9)Failure ("LessThan10" :| [])"runValidator pairValidator ("", 9))Failure ("EmptyString" :| ["LessThan10"])?validaA synonym for > with its arguments flipped.@valida5Fix a validator's output to be the same as its input. fixV . fixV = r . fixV Z (N x) . fixV = Z (N x)Note: The primitive and derivative combinators already fix the validator output to be the same as its input.ExamplesThis is useful for regaining the input value in the output position after multiple Zs.Assume we have a validator that fails when input number is even-)let evenValidator = failureIf even "Even"This validator, when run, will yield its input value, wrapped in , if input is not even. @ would be redundant on this.However, if the output was Zed to be something else--let evenValidator' = fmap (:[]) evenValidatorNow the output type is `[Int]`. The value of the output is no longer the same as the input. If we needed to get the original input back into the output, @ would be the right choice.)let evenValidator'' = fixV evenValidator'evenValidator'' is now the exact same as evenValidator, which was fixed from the start.(("foo" <$ failureIf even "Even") <> ("bar" <$ failureIf (<0) "Negative")) `runValidator` 5 Success "bar"fixV (("foo" <$ failureIf even "Even") <> ("bar" <$ failureIf (<0) "Negative")) `runValidator` 5 Success 5Avalida Relabel a  with a different error.Examples5let validator = label "NotEven" (failureUnless' even)runValidator validator 1Failure "NotEven"let validator = label "DefinitelyNotEven" (failureUnless even "NotEven")runValidator validator 1Failure "DefinitelyNotEven"BvalidaA synonym for A with its arguments flipped.  !"#$%&'()*+,-./0123456789:;<=>?@AB@>?AB  ?5B6 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\Z]^Z_`abZcdZ_efZ gZ_hijZ_klZ_mnopqoprstZ_uvwxyzZ {Z |Z}~Z Z Z Z Z Z Z ZZZZ_#valida-1.1.0-1OWznLLvHBZISPeSnxVNVrValidaValida.Combinators Paths_valida Valida.UtilsValida.ValidationValida.ValidationUtilsValida.ValidatorData.Functor.Contravariant Predicate Data.Foldablefold Data.Maybe fromMaybe ValidationFailureSuccess validationvalidationConsttoEither fromEither isFailure isSuccess fromFailure fromSuccessfailures successespartitionValidations Validator runValidator failureIf failureUnless failureIf'failureUnless'mustBeofLength minLengthOf maxLengthOf lengthAbove lengthBelownotEmpty lengthWithin minValueOf maxValueOf valueAbove valueBelow valueWithin onlyContainsatleastContains mustContainmustBe' ofLength' minLengthOf' maxLengthOf' lengthAbove' lengthBelow' notEmpty' lengthWithin' minValueOf' maxValueOf' valueAbove' valueBelow' valueWithin' onlyContains'atleastContains' mustContain'negateVnegateV'orElsefailVandAlso satisfyAny satisfyAll optionally withDefaultverify-?>fixVlabelversion getBinDir getLibDir getDynLibDir getDataDir getLibexecDir getSysconfDirgetDataFileName neSingletonbase Data.EitherEitherData.Bifoldable bifoldMapGHC.Baseconst$fBifoldableValidation$fTraversableValidationData.Traversabletraversepure$fFoldableValidationfoldMapmempty$fSemigroupValidation$fApplicativeValidation<*>$fFunctorValidationfmap$fProfunctorValidator(profunctors-5.6.2-3WjoZ0635rf7ghFP8aUpMUData.Profunctor.Unsafelmaprmap$fMonoidValidator$fSemigroupValidator<>$fApplicativeValidator$fFunctorValidatorghc-prim GHC.ClassesnotlengthnullGHC.IxinRangeallanyelemfoldl1foldr1foldlfoldr GHC.MaybeJustNothing Data.Functor<$>id