-- 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.4.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 -- | 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 a b = Pred a -> Pred b -- | Operate on the target of a prism, or fail. match :: APrism s t a b -> PT a s -- | Invert a predicate. nay :: PT a a -- | Operate on the Just branch of a Maybe, or fail. just :: PT a (Maybe a) -- | Operate on the Left branch of an Either, or fail. left :: PT e (Either e a) -- | Operate on the Right branch of an Either, or fail. right :: PT a (Either e a) -- | Operate on the last value in a foldable, or fail if it's not present. endingWith :: Foldable f => PT a (f a) -- | Operate on the first value in a foldable, or fail if it's not present. startingWith :: Foldable f => PT a (f a) -- | Require that a foldable has a single element, and operate on that -- element. only :: Foldable f => PT a (f a) -- | Only test the kth element of a foldable. kth :: Foldable f => Int -> PT 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 :: [Pred a] -> Pred [a] -- | 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 :: (Eq (f ()), Functor f, Foldable f) => f (Pred a) -> Pred (f a) -- | Given a representable functor-full of predicates, and a functor-full -- of values, yield a representable functor-full of booleans. Similar to -- distF. distRep :: Representable f => f (a -> Bool) -> f a -> f Bool -- | Test all predicates against one value. allTrue :: [Pred a] -> Pred a -- | 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 :: Getting (All, Any) s a -> PT a s -- | Sugar for tupling. (==>) :: a -> b -> (a, b) pair :: Pred a -> Pred b -> Pred (a, b) -- | 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