@@ -80,6 +80,8 @@ module Reflex.Class
80 , mapAccumMaybe_
80 , mapAccumMaybe_
81 , mapAccumMaybeM_
81 , mapAccumMaybeM_
82 , zipListWithEvent
82 , zipListWithEvent
84+ , numberOccurrencesFrom
85 , headTailE
87 , headTailE
@@ -916,6 +918,14 @@ zipListWithEvent f l e = do
916 _ -> (Nothing, Nothing) --TODO: Unsubscribe the event?
918 _ -> (Nothing, Nothing) --TODO: Unsubscribe the event?
917 mapAccumMaybe_ f' l e
919 mapAccumMaybe_ f' l e
921+-- | Assign a number to each occurence of the given 'Event', starting from 0
922+numberOccurrences :: (Reflex t, MonadHold t m, MonadFix m, Num b) => Event t a -> m (Event t (b, a))
923+numberOccurrences = numberOccurrencesFrom 0
925+-- | Assign a number to each occurence of the given 'Event'
926+numberOccurrencesFrom :: (Reflex t, MonadHold t m, MonadFix m, Num b) => b -> Event t a -> m (Event t (b, a))
927+numberOccurrencesFrom = mapAccum_ (\n a -> (n + 1, (n, a)))
919-- | A 'Monad' that supports adjustment over time. After an action has been
929-- | A 'Monad' that supports adjustment over time. After an action has been
920-- run, if the given events fire, it will adjust itself so that its net effect
930-- run, if the given events fire, it will adjust itself so that its net effect
921-- is as though it had originally been run with the new value. Note that there
931-- is as though it had originally been run with the new value. Note that there