packages feed

rec-def 0.2.1 → 0.2.2

raw patch · 3 files changed

+22/−4 lines, 3 filesdep ~containers

Dependency ranges changed: containers

Files

CHANGELOG.md view
@@ -1,5 +1,13 @@ # Revision history for rec-def +## 0.2.2 -- 2023-08-19++* Add `RMap.map` and `RMap.mapWithKey`++## 0.2.1 -- 2023-02-18++* Add `Data.Recursive.Set.when`+ ## 0.2 -- 2022-09-22  * The naive propagator does not use `(==)` to detect changes, but a custom
Data/Recursive/Map.hs view
@@ -30,11 +30,11 @@  :} fromList [(23,fromList ["Hi"])] -I am looking for a concice but useful example for this feature to be put here! +I am looking for a concice but useful example for this feature to be put here!  An alternative would be to order these maps using a pointwise order on the maps of elements (and do a simple fixed-point iteration underneath). But then we-could provide a general 'RM.unionWith' function, because not every function+could not provide a general 'RM.unionWith' function, because not every function passed to it would be monotone.  -}@@ -60,11 +60,14 @@   , notMember   , disjoint   , Data.Recursive.Map.null+  , map+  , mapWithKey   , fromSet   , keysSet   , restrictKeys   ) where +import Prelude hiding (map) import qualified Data.Map as M  import Data.Recursive.Internal@@ -154,6 +157,13 @@ intersectionWithKey :: Ord a => (a -> b -> b -> b) -> RMap a b -> RMap a b -> RMap a b intersectionWithKey f ~(RMap rs1 m1) ~(RMap rs2 m2) = build (RS.intersection rs1 rs2) (M.intersectionWithKey f m1 m2) +-- | prop> RM.get (RM.map (applyFun f) m) === M.map (applyFun f) (RM.get m)+map :: Ord k => (a -> b) -> RMap k a -> RMap k b+map f ~(RMap rs m) = build (RS.id rs) (M.map f m)++-- | prop> RM.get (RM.mapWithKey (applyFun2 f) m) === M.mapWithKey (applyFun2 f) (RM.get m)+mapWithKey :: Ord k => (k -> a -> b) -> RMap k a -> RMap k b+mapWithKey f ~(RMap rs m) = build (RS.id rs) (M.mapWithKey f m)  -- | prop> RM.get (RM.singleton k v) === M.singleton k v fromSet :: (a -> b) -> RS.RSet a -> RMap a b
rec-def.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               rec-def-version:            0.2.1+version:            0.2.2 synopsis:           Recursively defined values description:    This library provides safe APIs that allow you to define and calculate@@ -50,7 +50,7 @@     CHANGELOG.md     README.md     examples.hs-tested-with: GHC==9.2.1, GHC==9.0.2, GHC==8.10.7, GHC==8.8.4+tested-with: GHC==9.6.1 GHC==9.4.4 GHC==9.2.7, GHC==9.0.2, GHC==8.10.7, GHC==8.8.4  library     exposed-modules: Data.Recursive.Examples