@@ -189,6 +189,13 @@ applyMap olds diffs = flip Map.mapMaybe (align olds diffs) $ \case
189189 These _ new -> new
190190 That new -> new
191191
192+--HACK: A listWithKey that is inefficient but works around a subtle buggy interaction with DynamicWriterT
193+listWithKey :: forall t k v m a. (Ord k, MonadWidget t m) => Dynamic t (Map k v) -> (k -> Dynamic t v -> m a) -> m (Dynamic t (Map k a))
194+listWithKey eltsMapD body = do
195+ pb <- getPostBuild
196+ widgetHold (return Map.empty) $ ffor (leftmost [ tagDyn eltsMapD pb, updated eltsMapD ]) $ imapM $ \k v -> body k (constDyn v)
197+
198+{-
192199--TODO: Something better than Dynamic t (Map k v) - we want something where the Events carry diffs, not the whole value
193200listWithKey :: forall t k v m a. (Ord k, MonadWidget t m) => Dynamic t (Map k v) -> (k -> Dynamic t v -> m a) -> m (Dynamic t (Map k a))
194201listWithKey vals mkChild = do
@@ -201,6 +208,7 @@ listWithKey vals mkChild = do
201208 ]
202209 listWithKeyShallowDiff Map.empty changeVals $ \k v0 dv -> do
203210 mkChild k =<< holdDyn v0 dv
211+-}
204212
205213{-# DEPRECATED listWithKey' "listWithKey' has been renamed to listWithKeyShallowDiff; also, its behavior has changed to fix a bug where children were always rebuilt (never updated)" #-}
206214listWithKey' :: (Ord k, MonadWidget t m) => Map k v -> Event t (Map k (Maybe v)) -> (k -> v -> Event t v -> m a) -> m (Dynamic t (Map k a))
@@ -278,6 +286,7 @@ listHoldWithKey initialVals valsChanged mkChild = do
278286listViewWithKey :: (Ord k, MonadWidget t m) => Dynamic t (Map k v) -> (k -> Dynamic t v -> m (Event t a)) -> m (Event t (Map k a))
279287listViewWithKey vals mkChild = liftM (switch . fmap mergeMap) $ listViewWithKey' vals mkChild
280288
289+
281290listViewWithKey' :: (Ord k, MonadWidget t m) => Dynamic t (Map k v) -> (k -> Dynamic t v -> m a) -> m (Behavior t (Map k a))
282291listViewWithKey' vals mkChild = liftM current $ listWithKey vals mkChild
283292