predicate-transformers 0.11.0.0 → 0.12.0.0
raw patch · 3 files changed
+22/−7 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- PredicateTransformers: infixr 9 !
- PredicateTransformers: sole :: (Predicatory p, Foldable f) => PT p a (f a)
- PredicateTransformers: soleOf :: Predicatory p => Fold s a -> PT p a s
+ PredicateTransformers: (?) :: (a -> b) -> a -> b
+ PredicateTransformers: infixl 9 ?
+ PredicateTransformers: infixr 8 !
+ PredicateTransformers: satAll :: Predicatory p => [a -> p] -> a -> p
+ PredicateTransformers: soleElement :: (Predicatory p, Foldable f) => PT p a (f a)
+ PredicateTransformers: soleElementOf :: Predicatory p => Fold s a -> PT p a s
Files
- CHANGELOG.md +6/−0
- predicate-transformers.cabal +1/−1
- src/PredicateTransformers.hs +15/−6
CHANGELOG.md view
@@ -1,5 +1,11 @@ # Revision history for predicate-transformers +## 0.12.0.0 -- 2024-07-23+* Rename `sole` to `soleElement`+* Add `?`, an infix function application operator with lower+ precedence than `!`.+* Add `satAll = foldr also continue`.+ ## 0.11.0.0 -- 2024-07-21 * Add documentation. * Rename `onlyContains` to `sole`. Add `soleOf`, generalizing over `Fold`s.
predicate-transformers.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.4 name: predicate-transformers-version: 0.11.0.0+version: 0.12.0.0 synopsis: A library for writing predicates and transformations over predicates in Haskell description: This package provides ways to write predicates such that they compose nicely and are easy to debug.
src/PredicateTransformers.hs view
@@ -139,13 +139,13 @@ startingWith _ (toList -> []) = stop -- | Require that a @Fold@ has a single element, and operate on that element.-soleOf :: (Predicatory p) => Fold s a -> PT p a s-soleOf f p (toListOf f -> [x]) = p x-soleOf _ _ _ = stop+soleElementOf :: Predicatory p => Fold s a -> PT p a s+soleElementOf f p (toListOf f -> [x]) = p x+soleElementOf _ _ _ = stop -- | Require that a @Foldable@ has a single element, and operate on that element.-sole :: (Predicatory p, Foldable f) => PT p a (f a)-sole = soleOf folded+soleElement :: (Predicatory p, Foldable f) => PT p a (f a)+soleElement = soleElementOf folded -- | Only test the @k@th element of a foldable. kth :: (Predicatory p, Foldable f) => Int -> PT p a (f a)@@ -200,8 +200,13 @@ -- | Flipped function composition; @f !@ for a function @f@ is a predicate transformer. (!) :: (b -> a) -> (a -> c) -> b -> c (!) = flip (.)-infixr 9 !+infixr 8 ! +-- | Higher precedence @$@, to work well with '!'.+(?) :: (a -> b) -> a -> b+(?) = ($)+infixl 9 ?+ -- | Prints the input of a predicate, for debugging. traced :: Show a => (a -> String) -> PT c a a traced s p a = trace (s a) (p a)@@ -233,3 +238,7 @@ -- | Predicate on equality. equals :: (Predicatory p, Eq a) => a -> a -> p equals a a' = bool stop continue (a == a')++-- | Check that all of the input predicates are satisfied.+satAll :: Predicatory p => [a -> p] -> a -> p+satAll = foldr also continue