@@ -13,6 +13,8 @@ import Data.Align
13import Data.GADT.Compare (GEq (..), (:~:) (..))
13import Data.GADT.Compare (GEq (..), (:~:) (..))
14import Data.GADT.Show (GShow (..))
14import Data.GADT.Show (GShow (..))
15import Data.Dependent.Sum (ShowTag (..))
15import Data.Dependent.Sum (ShowTag (..))
17+import qualified Data.Map as Map
16import Data.Dependent.Map (DMap, DSum (..), GCompare (..), GOrdering (..))
18import Data.Dependent.Map (DMap, DSum (..), GCompare (..), GOrdering (..))
17import qualified Data.Dependent.Map as DMap
19import qualified Data.Dependent.Map as DMap
18import Data.Functor.Misc
20import Data.Functor.Misc
@@ -216,6 +218,12 @@ mergeList :: Reflex t => [Event t a] -> Event t (NonEmpty a)
216mergeList [] = never
218mergeList [] = never
217mergeList es = mergeWith (<>) $ map (fmap (:|[])) es
219mergeList es = mergeWith (<>) $ map (fmap (:|[])) es
221+mergeMap :: (Reflex t, Ord k) => Map k (Event t a) -> Event t (Map k a)
222+mergeMap = fmap dmapToMap . merge . mapWithFunctorToDMap
224+fanMap :: (Reflex t, Ord k) => Event t (Map k a) -> EventSelector t (Const2 k a)
225+fanMap = fan . fmap mapToDMap
219-- | Switches to the new event whenever it receives one; the new event is used immediately, on the same frame that it is switched to
227-- | Switches to the new event whenever it receives one; the new event is used immediately, on the same frame that it is switched to
220switchPromptly :: forall t m a. (Reflex t, MonadHold t m) => Event t a -> Event t (Event t a) -> m (Event t a)
228switchPromptly :: forall t m a. (Reflex t, MonadHold t m) => Event t a -> Event t (Event t a) -> m (Event t a)
221switchPromptly ea0 eea = do
229switchPromptly ea0 eea = do