@@ -13,6 +13,8 @@ import Data.Align
1313import Data.GADT.Compare (GEq (..), (:~:) (..))
1414import Data.GADT.Show (GShow (..))
1515import Data.Dependent.Sum (ShowTag (..))
16+import Data.Map (Map)
17+import qualified Data.Map as Map
1618import Data.Dependent.Map (DMap, DSum (..), GCompare (..), GOrdering (..))
1719import qualified Data.Dependent.Map as DMap
1820import Data.Functor.Misc
@@ -216,6 +218,12 @@ mergeList :: Reflex t => [Event t a] -> Event t (NonEmpty a)
216218mergeList [] = never
217219mergeList es = mergeWith (<>) $ map (fmap (:|[])) es
218220
221+mergeMap :: (Reflex t, Ord k) => Map k (Event t a) -> Event t (Map k a)
222+mergeMap = fmap dmapToMap . merge . mapWithFunctorToDMap
223+
224+fanMap :: (Reflex t, Ord k) => Event t (Map k a) -> EventSelector t (Const2 k a)
225+fanMap = fan . fmap mapToDMap
226+
219227-- | Switches to the new event whenever it receives one; the new event is used immediately, on the same frame that it is switched to
220228switchPromptly :: forall t m a. (Reflex t, MonadHold t m) => Event t a -> Event t (Event t a) -> m (Event t a)
221229switchPromptly ea0 eea = do