diff --git a/ChangeLog.md b/ChangeLog.md index 0fb72ce..fd0308a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,9 @@ # Revision history for patch +## 0.0.8.5 + +* Strict `apply` for `PatchIntMap`, bringing it in line with the other `Map` types. + ## 0.0.8.4 * Support for GHC 9.12 diff --git a/src/Data/Patch/IntMap.hs b/src/Data/Patch/IntMap.hs index f483f7f..8ffc52a 100644 --- a/src/Data/Patch/IntMap.hs +++ b/src/Data/Patch/IntMap.hs @@ -50,7 +50,7 @@ makeWrapped ''PatchIntMap -- | Apply the insertions or deletions to a given 'IntMap'. instance Patch (PatchIntMap a) where type PatchTarget (PatchIntMap a) = IntMap a - apply (PatchIntMap p) v = if IntMap.null p then Nothing else Just $ + apply (PatchIntMap p) v = if IntMap.null p then Nothing else Just $! let removes = IntMap.filter isNothing p adds = IntMap.mapMaybe id p in IntMap.union adds $ v `IntMap.difference` removes