@@ -33,6 +33,8 @@ import qualified Data.Dependent.Map as DMap
3333import Data.Dependent.Sum (DSum (..))
3434import Data.Functor.Compose
3535import Data.Functor.Constant
36+import Data.IntMap (IntMap)
37+import qualified Data.IntMap as IntMap
3638import qualified Data.Map as Map
3739import Data.Map.Misc (applyMap)
3840import Data.Monoid
@@ -164,6 +166,7 @@ instance (Reflex t, Adjustable t m, MonadHold t m, SupportsStaticDomBuilder t m)
164166 StaticDomBuilderT $ modify $ (:) $ join o
165167 replaceEnd key
166168 return (fst result0, fmapCheap fst result')
169+ traverseIntMapWithKeyWithAdjust = hoistIntMapWithKeyWithAdjust traverseIntMapWithKeyWithAdjust
167170 traverseDMapWithKeyWithAdjust = hoistDMapWithKeyWithAdjust traverseDMapWithKeyWithAdjust mapPatchDMap
168171 traverseDMapWithKeyWithAdjustWithMove = hoistDMapWithKeyWithAdjust traverseDMapWithKeyWithAdjustWithMove mapPatchDMapWithMove
169172
@@ -177,6 +180,42 @@ replaceStart = do
177180replaceEnd :: DomBuilder t m => Text -> m ()
178181replaceEnd key = void $ commentNode $ def { _commentNodeConfig_initialContents = "replace-end" <> key }
179182
183+hoistIntMapWithKeyWithAdjust :: forall t m p a b.
184+ ( Adjustable t m
185+ , MonadHold t m
186+ , Patch (p a)
187+ , Functor p
188+ , Patch (p (Behavior t Builder))
189+ , PatchTarget (p (Behavior t Builder)) ~ IntMap (Behavior t Builder)
190+ , Ref m ~ IORef, MonadIO m, MonadFix m, PerformEvent t m, MonadReflexCreateTrigger t m, MonadRef m -- TODO remove
191+ )
192+ => (forall x. (IntMap.Key -> a -> m x)
193+ -> IntMap a
194+ -> Event t (p a)
195+ -> m (IntMap x, Event t (p x))
196+ ) -- ^ The base monad's traversal
197+ -> (IntMap.Key -> a -> StaticDomBuilderT t m b)
198+ -> IntMap a
199+ -> Event t (p a)
200+ -> StaticDomBuilderT t m (IntMap b, Event t (p b))
201+hoistIntMapWithKeyWithAdjust base f im0 im' = do
202+ key <- replaceStart
203+ e <- StaticDomBuilderT ask
204+ (children0, children') <- lift $ base (\k v -> runStaticDomBuilderT (f k v) e) im0 im'
205+ let result0 = IntMap.map fst children0
206+ result' = (fmap . fmap) fst children'
207+ outputs0 :: IntMap (Behavior t Builder)
208+ outputs0 = IntMap.map snd children0
209+ outputs' :: Event t (p (Behavior t Builder))
210+ outputs' = (fmap . fmap) snd children'
211+ outputs <- holdIncremental outputs0 outputs'
212+ StaticDomBuilderT $ modify $ (:) $ pull $ do
213+ os <- sample $ currentIncremental outputs
214+ fmap mconcat $ forM (IntMap.toList os) $ \(_, o) -> do
215+ sample o
216+ replaceEnd key
217+ return (result0, result')
218+
180219hoistDMapWithKeyWithAdjust :: forall (k :: * -> *) v v' t m p.
181220 ( Adjustable t m
182221 , MonadHold t m