Safe Haskell | None |
---|---|
Language | Haskell2010 |
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.
Synopsis
- type Pred a = a -> Bool
- type FT c a b = (a -> c) -> b -> c
- type PT a b = FT Bool a b
- match :: APrism s t a b -> PT a s
- getter :: Getting a s a -> FT c a s
- nay :: PT a a
- just :: PT a (Maybe a)
- left :: PT e (Either e a)
- right :: PT a (Either e a)
- endingWith :: Foldable f => PT a (f a)
- startingWith :: Foldable f => PT a (f a)
- only :: Foldable f => PT a (f a)
- dist :: [Pred a] -> Pred [a]
- distF :: (Eq (f ()), Functor f, Foldable f) => f (Pred a) -> Pred (f a)
- distRep :: Representable f => f (a -> Bool) -> f a -> f Bool
- checkAll :: Monoid m => [a -> m] -> a -> m
- sumOver :: (Monoid m, Plated a) => FT m a a
- (==>) :: a -> b -> (a, b)
- pair :: Pred a -> Pred b -> Pred (a, b)
- (!) :: (b -> a) -> FT c a b
- traced :: Show a => FT c a a
Documentation
type FT c a b = (a -> c) -> b -> c Source #
Close to a CPS transform of b -> a
, except that c
isn't quantified over.
Stands for "function transformer".
endingWith :: Foldable f => PT a (f a) Source #
Operate on the last value in a list, or fail if it's not present.
startingWith :: Foldable f => PT a (f a) Source #
Operate on the first value in a list, or fail if it's not present.
only :: Foldable f => PT a (f a) Source #
Require that a list has a single element, and operate on that element.
dist :: [Pred a] -> Pred [a] Source #
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.
distF :: (Eq (f ()), Functor f, Foldable f) => f (Pred a) -> Pred (f a) Source #
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 dist
.
distRep :: Representable f => f (a -> Bool) -> f a -> f Bool Source #
Given a representable functor-full of predicates, and a functor-full of values,
yield a representable functor-full of booleans. Similar to distF
.
sumOver :: (Monoid m, Plated a) => FT m a a Source #
Given a plated type, take a monoidal sum over every child recursively, bottom-up.