on develop help sign in
Implement traverseIntMapWithKeyWithAdjust for DynamicWriter
01cef41Ryan Trinkle
reflex.cabal+1
@@ -98,6 +98,7 @@ library
98 Reflex.Patch.Class,
98 Reflex.Patch.Class,
99 Reflex.Patch.DMap,
99 Reflex.Patch.DMap,
100 Reflex.Patch.DMapWithMove,
100 Reflex.Patch.DMapWithMove,
101+ Reflex.Patch.IntMap,
101 Reflex.Patch.Map,
102 Reflex.Patch.Map,
102 Reflex.Patch.MapWithMove,
103 Reflex.Patch.MapWithMove,
103 Reflex.TriggerEvent.Base,
104 Reflex.TriggerEvent.Base,
src/Data/FastMutableIntMap.hs+4−24
@@ -26,14 +26,15 @@ module Data.FastMutableIntMap
26--TODO: Fast copy to FastIntMap
26--TODO: Fast copy to FastIntMap
27--TODO: Fast patch type
27--TODO: Fast patch type
28
28
29−import Prelude hiding (lookup)
29+import Control.Monad.IO.Class
30+import Data.Foldable (traverse_)
30import Data.IORef
31import Data.IORef
31import Data.IntMap.Strict (IntMap)
32import Data.IntMap.Strict (IntMap)
32import qualified Data.IntMap.Strict as IntMap
33import qualified Data.IntMap.Strict as IntMap
33import Data.Maybe
34import Data.Maybe
35+import Prelude hiding (lookup)
34import Reflex.Patch.Class
36import Reflex.Patch.Class
35−import Data.Foldable (traverse_)
37+import Reflex.Patch.IntMap
36−import Control.Monad.IO.Class
37
38
38newtype FastMutableIntMap a = FastMutableIntMap (IORef (IntMap a))
39newtype FastMutableIntMap a = FastMutableIntMap (IORef (IntMap a))
39
40
@@ -77,24 +78,3 @@ applyPatch (FastMutableIntMap r) p@(PatchIntMap m) = do
77 v <- readIORef r
78 v <- readIORef r
78 writeIORef r $! applyAlways p v
79 writeIORef r $! applyAlways p v
79 return $ IntMap.intersection v m
80 return $ IntMap.intersection v m
80−
81−newtype PatchIntMap a = PatchIntMap (IntMap (Maybe a)) deriving (Functor, Foldable, Traversable, Monoid)
82−
83−instance Patch (PatchIntMap a) where
84− type PatchTarget (PatchIntMap a) = IntMap a
85− apply (PatchIntMap p) v = if IntMap.null p then Nothing else Just $
86− let removes = IntMap.filter isNothing p
87− adds = IntMap.mapMaybe id p
88− in IntMap.union adds $ v `IntMap.difference` removes
89−
90−traverseIntMapPatchWithKey :: Applicative t => (Int -> a -> t b) -> PatchIntMap a -> t (PatchIntMap b)
91−traverseIntMapPatchWithKey f (PatchIntMap m) = PatchIntMap <$> IntMap.traverseWithKey (\k mv -> traverse (f k) mv) m
92−
93−patchIntMapNewElements :: PatchIntMap a -> [a]
94−patchIntMapNewElements (PatchIntMap m) = catMaybes $ IntMap.elems m
95−
96−patchIntMapNewElementsMap :: PatchIntMap a -> IntMap a
97−patchIntMapNewElementsMap (PatchIntMap m) = IntMap.mapMaybe id m
98−
99−getDeletions :: PatchIntMap v -> IntMap v' -> IntMap v'
100−getDeletions (PatchIntMap m) v = IntMap.intersection v m
src/Data/Functor/Misc.hs+13
@@ -23,6 +23,7 @@ module Data.Functor.Misc
23 Const2 (..)
23 Const2 (..)
24 , unConst2
24 , unConst2
25 , dmapToMap
25 , dmapToMap
26+ , dmapToIntMap
26 , dmapToMapWith
27 , dmapToMapWith
27 , mapToDMap
28 , mapToDMap
28 , weakenDMapWith
29 , weakenDMapWith
@@ -30,6 +31,7 @@ module Data.Functor.Misc
30 , WrapArg (..)
31 , WrapArg (..)
31 -- * Convenience functions for DMap
32 -- * Convenience functions for DMap
32 , mapWithFunctorToDMap
33 , mapWithFunctorToDMap
34+ , intMapWithFunctorToDMap
33 , mapKeyValuePairsMonotonic
35 , mapKeyValuePairsMonotonic
34 , combineDMapsWithKey
36 , combineDMapsWithKey
35 , EitherTag (..)
37 , EitherTag (..)
@@ -53,6 +55,8 @@ import qualified Data.Dependent.Map as DMap
53import Data.Dependent.Sum
55import Data.Dependent.Sum
54import Data.GADT.Compare
56import Data.GADT.Compare
55import Data.GADT.Show
57import Data.GADT.Show
58+import Data.IntMap (IntMap)
59+import qualified Data.IntMap as IntMap
56import Data.Map (Map)
60import Data.Map (Map)
57import qualified Data.Map as Map
61import qualified Data.Map as Map
58import Data.Some (Some)
62import Data.Some (Some)
@@ -127,6 +131,10 @@ instance {-# INCOHERENT #-} Eq k => EqTag (Const2 k v) (Const2 k v) where
127dmapToMap :: DMap (Const2 k v) Identity -> Map k v
131dmapToMap :: DMap (Const2 k v) Identity -> Map k v
128dmapToMap = Map.fromDistinctAscList . map (\(Const2 k :=> Identity v) -> (k, v)) . DMap.toAscList
132dmapToMap = Map.fromDistinctAscList . map (\(Const2 k :=> Identity v) -> (k, v)) . DMap.toAscList
129
133
134+-- | Convert a 'DMap' to an 'IntMap'
135+dmapToIntMap :: DMap (Const2 IntMap.Key v) Identity -> IntMap v
136+dmapToIntMap = IntMap.fromDistinctAscList . map (\(Const2 k :=> Identity v) -> (k, v)) . DMap.toAscList
137+
130-- | Convert a 'DMap' to a regular 'Map', applying the given function to remove
138-- | Convert a 'DMap' to a regular 'Map', applying the given function to remove
131-- the wrapping 'Functor'
139-- the wrapping 'Functor'
132dmapToMapWith :: (f v -> v') -> DMap (Const2 k v) f -> Map k v'
140dmapToMapWith :: (f v -> v') -> DMap (Const2 k v) f -> Map k v'
@@ -141,6 +149,11 @@ mapToDMap = DMap.fromDistinctAscList . map (\(k, v) -> Const2 k :=> Identity v)
141mapWithFunctorToDMap :: Map k (f v) -> DMap (Const2 k v) f
149mapWithFunctorToDMap :: Map k (f v) -> DMap (Const2 k v) f
142mapWithFunctorToDMap = DMap.fromDistinctAscList . map (\(k, v) -> Const2 k :=> v) . Map.toAscList
150mapWithFunctorToDMap = DMap.fromDistinctAscList . map (\(k, v) -> Const2 k :=> v) . Map.toAscList
143
151
152+-- | Convert a regular 'IntMap', where the values are already wrapped in a
153+-- functor, to a 'DMap'
154+intMapWithFunctorToDMap :: IntMap (f v) -> DMap (Const2 IntMap.Key v) f
155+intMapWithFunctorToDMap = DMap.fromDistinctAscList . map (\(k, v) -> Const2 k :=> v) . IntMap.toAscList
156+
144-- | Convert a 'DMap' to a regular 'Map' by forgetting the types associated with
157-- | Convert a 'DMap' to a regular 'Map' by forgetting the types associated with
145-- the keys, using a function to remove the wrapping 'Functor'
158-- the keys, using a function to remove the wrapping 'Functor'
146weakenDMapWith :: (forall a. v a -> v') -> DMap k v -> Map (Some k) v'
159weakenDMapWith :: (forall a. v a -> v') -> DMap k v -> Map (Some k) v'
src/Reflex/Class.hs+5
@@ -48,6 +48,7 @@ module Reflex.Class
48 , mergeMap
48 , mergeMap
49 , mergeMapIncremental
49 , mergeMapIncremental
50 , mergeMapIncrementalWithMove
50 , mergeMapIncrementalWithMove
51+ , mergeIntMapIncremental
51 , mergeList
52 , mergeList
52 , mergeWith
53 , mergeWith
53 , difference
54 , difference
@@ -792,6 +793,10 @@ mergeMap = fmap dmapToMap . merge . mapWithFunctorToDMap
792mergeMapIncremental :: (Reflex t, Ord k) => Incremental t (PatchMap k (Event t a)) -> Event t (Map k a)
793mergeMapIncremental :: (Reflex t, Ord k) => Incremental t (PatchMap k (Event t a)) -> Event t (Map k a)
793mergeMapIncremental = fmap dmapToMap . mergeIncremental . unsafeMapIncremental mapWithFunctorToDMap (const2PatchDMapWith id)
794mergeMapIncremental = fmap dmapToMap . mergeIncremental . unsafeMapIncremental mapWithFunctorToDMap (const2PatchDMapWith id)
794
795
796+-- | Create a merge whose parents can change over time
797+mergeIntMapIncremental :: Reflex t => Incremental t (PatchIntMap (Event t a)) -> Event t (IntMap a)
798+mergeIntMapIncremental = fmap dmapToIntMap . mergeIncremental . unsafeMapIncremental intMapWithFunctorToDMap (const2IntPatchDMapWith id)
799+
795-- | Experimental: Create a merge whose parents can change over time; changing the key of an Event is more efficient than with mergeIncremental
800-- | Experimental: Create a merge whose parents can change over time; changing the key of an Event is more efficient than with mergeIncremental
796mergeMapIncrementalWithMove :: (Reflex t, Ord k) => Incremental t (PatchMapWithMove k (Event t a)) -> Event t (Map k a)
801mergeMapIncrementalWithMove :: (Reflex t, Ord k) => Incremental t (PatchMapWithMove k (Event t a)) -> Event t (Map k a)
797mergeMapIncrementalWithMove = fmap dmapToMap . mergeIncrementalWithMove . unsafeMapIncremental mapWithFunctorToDMap (const2PatchDMapWithMoveWith id)
802mergeMapIncrementalWithMove = fmap dmapToMap . mergeIncrementalWithMove . unsafeMapIncremental mapWithFunctorToDMap (const2PatchDMapWithMoveWith id)
src/Reflex/DynamicWriter.hs+32
@@ -30,7 +30,10 @@ import Control.Monad.State.Strict
30import Data.Align
30import Data.Align
31import Data.Dependent.Map (DMap)
31import Data.Dependent.Map (DMap)
32import qualified Data.Dependent.Map as DMap
32import qualified Data.Dependent.Map as DMap
33+import Data.FastMutableIntMap
33import Data.Functor.Misc
34import Data.Functor.Misc
35+import Data.IntMap (IntMap)
36+import qualified Data.IntMap as IntMap
34import Data.Map (Map)
37import Data.Map (Map)
35import qualified Data.Map as Map
38import qualified Data.Map as Map
36import Data.Semigroup
39import Data.Semigroup
@@ -55,6 +58,11 @@ mergeDynIncremental a = unsafeBuildIncremental (mapM (sample . current) =<< samp
55 where changedValues = fmap (PatchMap . fmap Just) $ mergeMapIncremental $ mapIncrementalMapValues updated a
58 where changedValues = fmap (PatchMap . fmap Just) $ mergeMapIncremental $ mapIncrementalMapValues updated a
56 addedAndRemovedValues = flip pushAlways (updatedIncremental a) $ \(PatchMap m) -> PatchMap <$> mapM (mapM (sample . current)) m
59 addedAndRemovedValues = flip pushAlways (updatedIncremental a) $ \(PatchMap m) -> PatchMap <$> mapM (mapM (sample . current)) m
57
60
61+mergeIntMapDynIncremental :: Reflex t => Incremental t (PatchIntMap (Dynamic t v)) -> Incremental t (PatchIntMap v)
62+mergeIntMapDynIncremental a = unsafeBuildIncremental (mapM (sample . current) =<< sample (currentIncremental a)) $ addedAndRemovedValues <> changedValues
63+ where changedValues = fmap (PatchIntMap . fmap Just) $ mergeIntMapIncremental $ mapIncrementalMapValues updated a
64+ addedAndRemovedValues = flip pushAlways (updatedIncremental a) $ \(PatchIntMap m) -> PatchIntMap <$> mapM (mapM (sample . current)) m
65+
58mergeDynIncrementalWithMove :: forall t k v. (Reflex t, Ord k) => Incremental t (PatchMapWithMove k (Dynamic t v)) -> Incremental t (PatchMapWithMove k v)
66mergeDynIncrementalWithMove :: forall t k v. (Reflex t, Ord k) => Incremental t (PatchMapWithMove k (Dynamic t v)) -> Incremental t (PatchMapWithMove k v)
59mergeDynIncrementalWithMove a = unsafeBuildIncremental (mapM (sample . current) =<< sample (currentIncremental a)) $ alignWith f addedAndRemovedValues changedValues
67mergeDynIncrementalWithMove a = unsafeBuildIncremental (mapM (sample . current) =<< sample (currentIncremental a)) $ alignWith f addedAndRemovedValues changedValues
60 where changedValues = mergeMapIncrementalWithMove $ mapIncrementalMapValues updated a
68 where changedValues = mergeMapIncrementalWithMove $ mapIncrementalMapValues updated a
@@ -142,6 +150,7 @@ instance (Adjustable t m, MonadFix m, Monoid w, MonadHold t m, Reflex t) => Adju
142 (result0, result') <- lift $ runWithReplace (runDynamicWriterT a0) $ runDynamicWriterT <$> a'
150 (result0, result') <- lift $ runWithReplace (runDynamicWriterT a0) $ runDynamicWriterT <$> a'
143 tellDyn . join =<< holdDyn (snd result0) (snd <$> result')
151 tellDyn . join =<< holdDyn (snd result0) (snd <$> result')
144 return (fst result0, fst <$> result')
152 return (fst result0, fst <$> result')
153+ traverseIntMapWithKeyWithAdjust = traverseIntMapWithKeyWithAdjustImpl traverseIntMapWithKeyWithAdjust mergeIntMapDynIncremental
145 traverseDMapWithKeyWithAdjust = traverseDMapWithKeyWithAdjustImpl traverseDMapWithKeyWithAdjust mapPatchDMap weakenPatchDMapWith mergeDynIncremental
154 traverseDMapWithKeyWithAdjust = traverseDMapWithKeyWithAdjustImpl traverseDMapWithKeyWithAdjust mapPatchDMap weakenPatchDMapWith mergeDynIncremental
146 traverseDMapWithKeyWithAdjustWithMove = traverseDMapWithKeyWithAdjustImpl traverseDMapWithKeyWithAdjustWithMove mapPatchDMapWithMove weakenPatchDMapWithMoveWith mergeDynIncrementalWithMove
155 traverseDMapWithKeyWithAdjustWithMove = traverseDMapWithKeyWithAdjustImpl traverseDMapWithKeyWithAdjustWithMove mapPatchDMapWithMove weakenPatchDMapWithMoveWith mergeDynIncrementalWithMove
147
156
@@ -172,6 +181,29 @@ traverseDMapWithKeyWithAdjustImpl base mapPatch weakenPatchWith mergeMyDynIncrem
172 tellDyn $ fmap (mconcat . Map.elems) $ incrementalToDynamic $ mergeMyDynIncremental i
181 tellDyn $ fmap (mconcat . Map.elems) $ incrementalToDynamic $ mergeMyDynIncremental i
173 return (liftedResult0, liftedResult')
182 return (liftedResult0, liftedResult')
174
183
184+traverseIntMapWithKeyWithAdjustImpl :: forall t w v' p p' v m. (PatchTarget (p' (Dynamic t w)) ~ IntMap (Dynamic t w), PatchTarget (p' w) ~ IntMap w, Patch (p' w), Patch (p' (Dynamic t w)), MonadFix m, Monoid w, Reflex t, MonadHold t m, Functor p, p ~ p')
185+ => ( (IntMap.Key -> v -> m ((v', Dynamic t w)))
186+ -> IntMap v
187+ -> Event t (p v)
188+ -> m (IntMap (v', Dynamic t w), Event t (p (v', Dynamic t w)))
189+ )
190+ -> (Incremental t (p' (Dynamic t w)) -> Incremental t (p' w))
191+ -> (IntMap.Key -> v -> DynamicWriterT t w m v')
192+ -> IntMap v
193+ -> Event t (p v)
194+ -> DynamicWriterT t w m (IntMap v', Event t (p v'))
195+traverseIntMapWithKeyWithAdjustImpl base mergeMyDynIncremental f (dm0 :: IntMap v) dm' = do
196+ (result0, result') <- lift $ base (\k v -> runDynamicWriterT $ f k v) dm0 dm'
197+ let liftedResult0 = fmap fst result0
198+ liftedResult' = fmap (fmap fst) result'
199+ liftedWritten0 :: IntMap (Dynamic t w)
200+ liftedWritten0 = fmap snd result0
201+ liftedWritten' = fmap (fmap snd) result'
202+ --TODO: We should be able to improve the performance here by incrementally updating the mconcat of the merged Dynamics
203+ i <- holdIncremental liftedWritten0 liftedWritten'
204+ tellDyn $ fmap (mconcat . IntMap.elems) $ incrementalToDynamic $ mergeMyDynIncremental i
205+ return (liftedResult0, liftedResult')
206+
175-- | Map a function over the output of a 'DynamicWriterT'.
207-- | Map a function over the output of a 'DynamicWriterT'.
176withDynamicWriterT :: (Monoid w, Monoid w', Reflex t, MonadHold t m, MonadFix m)
208withDynamicWriterT :: (Monoid w, Monoid w', Reflex t, MonadHold t m, MonadFix m)
177 => (w -> w')
209 => (w -> w')
src/Reflex/EventWriter.hs−1
@@ -38,7 +38,6 @@ import Control.Monad.Ref
38import Control.Monad.State.Strict
38import Control.Monad.State.Strict
39import Data.Dependent.Map (DMap, DSum (..))
39import Data.Dependent.Map (DMap, DSum (..))
40import qualified Data.Dependent.Map as DMap
40import qualified Data.Dependent.Map as DMap
41−import Data.FastMutableIntMap
42import Data.Foldable
41import Data.Foldable
43import Data.Functor.Compose
42import Data.Functor.Compose
44import Data.Functor.Misc
43import Data.Functor.Misc
src/Reflex/Patch.hs+2−1
@@ -7,10 +7,11 @@ module Reflex.Patch
7 ) where
7 ) where
8
8
9import Reflex.Patch.Class as X
9import Reflex.Patch.Class as X
10−import Reflex.Patch.DMap as X
10+import Reflex.Patch.DMap as X hiding (getDeletions)
11import Reflex.Patch.DMapWithMove as X (PatchDMapWithMove, const2PatchDMapWithMoveWith, patchDMapWithMoveToPatchMapWithMoveWith, mapPatchDMapWithMove, weakenPatchDMapWithMoveWith, traversePatchDMapWithMoveWithKey, unsafePatchDMapWithMove, unPatchDMapWithMove)
11import Reflex.Patch.DMapWithMove as X (PatchDMapWithMove, const2PatchDMapWithMoveWith, patchDMapWithMoveToPatchMapWithMoveWith, mapPatchDMapWithMove, weakenPatchDMapWithMoveWith, traversePatchDMapWithMoveWithKey, unsafePatchDMapWithMove, unPatchDMapWithMove)
12import Reflex.Patch.Map as X
12import Reflex.Patch.Map as X
13import Reflex.Patch.MapWithMove as X (PatchMapWithMove, patchMapWithMoveNewElementsMap, patchMapWithMoveNewElements, unsafePatchMapWithMove, unPatchMapWithMove)
13import Reflex.Patch.MapWithMove as X (PatchMapWithMove, patchMapWithMoveNewElementsMap, patchMapWithMoveNewElements, unsafePatchMapWithMove, unPatchMapWithMove)
14+import Reflex.Patch.IntMap as X hiding (getDeletions)
14
15
15import Data.Semigroup (Semigroup (..), (<>))
16import Data.Semigroup (Semigroup (..), (<>))
16
17
src/Reflex/Patch/DMap.hs+7
@@ -8,11 +8,13 @@
8module Reflex.Patch.DMap where
8module Reflex.Patch.DMap where
9
9
10import Reflex.Patch.Class
10import Reflex.Patch.Class
11+import Reflex.Patch.IntMap
11import Reflex.Patch.Map
12import Reflex.Patch.Map
12
13
13import Data.Dependent.Map (DMap, DSum (..), GCompare (..))
14import Data.Dependent.Map (DMap, DSum (..), GCompare (..))
14import qualified Data.Dependent.Map as DMap
15import qualified Data.Dependent.Map as DMap
15import Data.Functor.Constant
16import Data.Functor.Constant
17+import qualified Data.IntMap as IntMap
16import Data.Functor.Misc
18import Data.Functor.Misc
17import qualified Data.Map as Map
19import qualified Data.Map as Map
18import Data.Semigroup (Semigroup (..))
20import Data.Semigroup (Semigroup (..))
@@ -55,6 +57,11 @@ const2PatchDMapWith f (PatchMap p) = PatchDMap $ DMap.fromDistinctAscList $ g <$
55 where g :: (k, Maybe v) -> DSum (Const2 k a) (ComposeMaybe f)
57 where g :: (k, Maybe v) -> DSum (Const2 k a) (ComposeMaybe f)
56 g (k, e) = Const2 k :=> ComposeMaybe (f <$> e)
58 g (k, e) = Const2 k :=> ComposeMaybe (f <$> e)
57
59
60+const2IntPatchDMapWith :: forall v f a. (v -> f a) -> PatchIntMap v -> PatchDMap (Const2 IntMap.Key a) f
61+const2IntPatchDMapWith f (PatchIntMap p) = PatchDMap $ DMap.fromDistinctAscList $ g <$> IntMap.toAscList p
62+ where g :: (IntMap.Key, Maybe v) -> DSum (Const2 IntMap.Key a) (ComposeMaybe f)
63+ g (k, e) = Const2 k :=> ComposeMaybe (f <$> e)
64+
58-- | Get the values that will be deleted if the given patch is applied to the
65-- | Get the values that will be deleted if the given patch is applied to the
59-- given 'DMap'. Includes values that will be replaced.
66-- given 'DMap'. Includes values that will be replaced.
60getDeletions :: GCompare k => PatchDMap k v -> DMap k v' -> DMap k v'
67getDeletions :: GCompare k => PatchDMap k v -> DMap k v' -> DMap k v'
src/Reflex/Patch/IntMap.hsnew file+50
@@ -0,0 +1,50 @@
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE DeriveFunctor #-}
3+{-# LANGUAGE DeriveFoldable #-}
4+{-# LANGUAGE DeriveTraversable #-}
5+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
6+{-# LANGUAGE TypeFamilies #-}
7+module Reflex.Patch.IntMap where
8+
9+import Prelude hiding (lookup)
10+import Data.IntMap.Strict (IntMap)
11+import qualified Data.IntMap.Strict as IntMap
12+import Data.Maybe
13+import Data.Semigroup
14+import Reflex.Patch.Class
15+
16+newtype PatchIntMap a = PatchIntMap (IntMap (Maybe a)) deriving (Functor, Foldable, Traversable, Monoid)
17+
18+instance Patch (PatchIntMap a) where
19+ type PatchTarget (PatchIntMap a) = IntMap a
20+ apply (PatchIntMap p) v = if IntMap.null p then Nothing else Just $
21+ let removes = IntMap.filter isNothing p
22+ adds = IntMap.mapMaybe id p
23+ in IntMap.union adds $ v `IntMap.difference` removes
24+
25+-- | @a <> b@ will apply the changes of @b@ and then apply the changes of @a@.
26+-- If the same key is modified by both patches, the one on the left will take
27+-- precedence.
28+instance Semigroup (PatchIntMap v) where
29+ PatchIntMap a <> PatchIntMap b = PatchIntMap $ a `mappend` b --TODO: Add a semigroup instance for Map
30+ -- PatchMap is idempotent, so stimes n is id for every n
31+#if MIN_VERSION_semigroups(0,17,0)
32+ stimes = stimesIdempotentMonoid
33+#else
34+ times1p n x = case compare n 0 of
35+ LT -> error "stimesIdempotentMonoid: negative multiplier"
36+ EQ -> mempty
37+ GT -> x
38+#endif
39+
40+traverseIntMapPatchWithKey :: Applicative t => (Int -> a -> t b) -> PatchIntMap a -> t (PatchIntMap b)
41+traverseIntMapPatchWithKey f (PatchIntMap m) = PatchIntMap <$> IntMap.traverseWithKey (\k mv -> traverse (f k) mv) m
42+
43+patchIntMapNewElements :: PatchIntMap a -> [a]
44+patchIntMapNewElements (PatchIntMap m) = catMaybes $ IntMap.elems m
45+
46+patchIntMapNewElementsMap :: PatchIntMap a -> IntMap a
47+patchIntMapNewElementsMap (PatchIntMap m) = IntMap.mapMaybe id m
48+
49+getDeletions :: PatchIntMap v -> IntMap v' -> IntMap v'
50+getDeletions (PatchIntMap m) v = IntMap.intersection v m
src/Reflex/PerformEvent/Base.hs−1
@@ -40,7 +40,6 @@ import Data.Coerce
40import Data.Dependent.Map (DMap)
40import Data.Dependent.Map (DMap)
41import qualified Data.Dependent.Map as DMap
41import qualified Data.Dependent.Map as DMap
42import Data.Dependent.Sum
42import Data.Dependent.Sum
43−import Data.FastMutableIntMap
44import Data.IntMap.Strict (IntMap)
43import Data.IntMap.Strict (IntMap)
45import qualified Data.IntMap.Strict as IntMap
44import qualified Data.IntMap.Strict as IntMap
46
45
src/Reflex/Requester/Base.hs−1
@@ -50,7 +50,6 @@ import Data.Coerce
50import Data.Dependent.Map (DMap, DSum (..))
50import Data.Dependent.Map (DMap, DSum (..))
51import qualified Data.Dependent.Map as DMap
51import qualified Data.Dependent.Map as DMap
52import qualified Data.Some as Some
52import qualified Data.Some as Some
53−import Data.FastMutableIntMap
54import Data.Functor.Compose
53import Data.Functor.Compose
55import Data.Functor.Misc
54import Data.Functor.Misc
56import Data.IntMap.Strict (IntMap)
55import Data.IntMap.Strict (IntMap)