predicate-transformers 0.13.0.0 → 0.14.0.0
raw patch · 3 files changed
+20/−4 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ PredicateTransformers: (?) :: (a -> b) -> a -> b
+ PredicateTransformers: infixl 9 ?
+ PredicateTransformers: match :: Predicatory p => Prism' s a -> PT p a s
Files
- CHANGELOG.md +7/−0
- predicate-transformers.cabal +1/−1
- src/PredicateTransformers.hs +12/−3
CHANGELOG.md view
@@ -1,5 +1,12 @@ # Revision history for predicate-transformers +## 0.14.0.0 -- 2024-08-23+* Add `?` back in as a useful operator to work with `&`; `&` can be used as a predicate applicator, and `?` can be used as a predicate transformer applicator, allowing for a form of infix binary application like `x & f ? y = f x y`.+* Add `match` back in as a type-restricted alias for `soleElementOf`.++## 0.13.0.0 -- 2024-07-23+* Remove `?`+ ## 0.12.0.0 -- 2024-07-23 * Rename `sole` to `soleElement` * Add `?`, an infix function application operator with lower
predicate-transformers.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.4 name: predicate-transformers-version: 0.13.0.0+version: 0.14.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
@@ -125,15 +125,15 @@ -- | Operate on the `Just` branch of a `Maybe`, or fail. just :: Predicatory p => PT p a (Maybe a)-just = allOf1 _Just+just = match _Just -- | Operate on the `Left` branch of an `Either`, or fail. left :: Predicatory p => PT p e (Either e a)-left = allOf1 _Left+left = match _Left -- | Operate on the `Right` branch of an `Either`, or fail. right :: Predicatory p => PT p a (Either e a)-right = allOf1 _Right+right = match _Right -- | 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)@@ -154,6 +154,10 @@ soleElement :: (Predicatory p, Foldable f) => PT p a (f a) soleElement = soleElementOf folded +-- | Require that a @Prism@ matches, and apply the predicate to its contents.+match :: Predicatory p => Prism' s a -> PT p a s+match = soleElementOf+ -- | Only test the @k@th element of a foldable. kth :: (Predicatory p, Foldable f) => Int -> PT p a (f a) kth k p = startingWith p . drop k . toList@@ -206,6 +210,11 @@ -- | Flipped function composition; @pt f@ for a function @f@ is a predicate transformer. pt :: (a -> b) -> PT p b a pt f p = p . f++-- | 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