-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A library for writing predicates and transformations over predicates in Haskell -- -- This package provides ways to write predicates such that they compose -- nicely and are easy to debug. @package predicate-transformers @version 0.8.0.0 -- | This library is based on the notion of a predicate transformer, the -- below type PT a b, which is a function from a to -- predicates on b. They act as a sort of compositional "matcher -- language". Composing these predicate transformers is meant to be -- analogous to composing optics and there are utilities for using -- predicate transformers with (lens-style) optics. -- -- Some predicate transformers provided by other libraries: all, -- any (base) either (base) allOf (lens) module PredicateTransformers class Predicatory a oneOfTwo :: Predicatory a => a -> a -> a also :: Predicatory a => a -> a -> a stop :: Predicatory a => a continue :: Predicatory a => a class Exceptional a assess :: Exceptional a => a -> IO () data PredicateFailed PredicateFailed :: PredicateFailed -- | A convenient alias for predicates. type Pred a = a -> Bool -- | Predicate transformers form a category where composition is ordinary -- function composition. Forms a category with . and id. -- Multiple are already provided by the standard library, for instance -- all and any. type PT p a b = (a -> p) -> (b -> p) -- | Operate on the target of a prism, or fail. match :: Predicatory p => APrism s t a b -> PT p a s -- | Operate on the Just branch of a Maybe, or fail. just :: Predicatory p => PT p a (Maybe a) -- | Operate on the Left branch of an Either, or fail. left :: Predicatory p => PT p e (Either e a) -- | Operate on the Right branch of an Either, or fail. right :: Predicatory p => PT p a (Either e a) -- | Operate on the last value in a foldable, or fail if it's not present. endingWith :: (Predicatory p, Foldable f) => PT p a (f a) -- | Operate on the first value in a foldable, or fail if it's not present. startingWith :: (Predicatory p, Foldable f) => PT p a (f a) -- | Require that a foldable has a single element, and operate on that -- element. only :: (Predicatory p, Foldable f) => PT p a (f a) -- | Only test the kth element of a foldable. kth :: (Predicatory p, Foldable f) => Int -> PT p a (f a) -- | Given a list of predicates and a list of values, ensure that each -- predicate holds for each respective value. Fails if the two lists have -- different lengths. list :: Predicatory p => [a -> p] -> [a] -> p -- | Given a functor-full of predicates, and a functor-full of values, -- ensure that the structures of the two functors match and apply all of -- the predicates to all of the values. Generalized version of -- list. dist :: (Predicatory p, Eq (f ()), Functor f, Foldable f) => f (a -> p) -> f a -> p -- | Given a representable functor-full of predicates, and a functor-full -- of values, yield a representable functor-full of booleans. Similar to -- dist. distRep :: Representable f => f (a -> p) -> f a -> f p -- | Test all predicates against one value. allTrue :: (Predicatory p, Foldable f) => f (a -> p) -> a -> p -- | Check that a predicate is true for all values behind a generalized -- getter and that there's at least one value for which it's true. allOf1 :: Predicatory p => Fold s a -> PT p a s -- | Sugar for tupling. (==>) :: a -> b -> (a, b) pair :: Predicatory p => (a -> p) -> (b -> p) -> (a, b) -> p -- | Flipped function composition; f ! for a function f -- is a predicate transformer. (!) :: (b -> a) -> (a -> c) -> b -> c -- | Prints the input of a predicate, for debugging. traced :: Show a => (a -> c) -> a -> c -- | Prints the input of a predicate, if the predicate fails. Requires that -- the predicate's output type includes a notion of failure. traceFail :: (Predicatory p, Exceptional p) => (a -> String) -> PT p a a traceFailShow :: (Exceptional p, Predicatory p, Show a) => PT p a a -- | Predicate which always succeeds. something :: Predicatory p => a -> p -- | Predicate which triggers full evaluation of its input and succeeds. -- Useful for testing that an exception isn't thrown. forced :: (Predicatory p, NFData a) => a -> p instance GHC.Show.Show PredicateTransformers.PredicateFailed instance GHC.Exception.Type.Exception PredicateTransformers.PredicateFailed instance PredicateTransformers.Predicatory (GHC.Types.IO ()) instance PredicateTransformers.Exceptional GHC.Types.Bool instance PredicateTransformers.Exceptional (GHC.Types.IO ()) instance PredicateTransformers.Predicatory GHC.Types.Bool