on develop help sign in
Merge branch 'with-event-writer' of github.com:dalaing/reflex into develop
9fd59f3Ryan Trinkle
src/Reflex/EventWriter.hs+14
@@ -20,6 +20,7 @@ module Reflex.EventWriter
20 , EventWriter (..)
20 , EventWriter (..)
21 , runWithReplaceEventWriterTWith
21 , runWithReplaceEventWriterTWith
22 , sequenceDMapWithAdjustEventWriterTWith
22 , sequenceDMapWithAdjustEventWriterTWith
23+ , withEventWriterT
23 ) where
24 ) where
24
25
25import Reflex.Class
26import Reflex.Class
@@ -267,3 +268,16 @@ instance (MonadQuery t q m, Monad m) => MonadQuery t q (EventWriterT t w m) wher
267 tellQueryIncremental = lift . tellQueryIncremental
268 tellQueryIncremental = lift . tellQueryIncremental
268 askQueryResult = lift askQueryResult
269 askQueryResult = lift askQueryResult
269 queryIncremental = lift . queryIncremental
270 queryIncremental = lift . queryIncremental
271+
272+-- | Map a function over the output of a 'EventWriterT'.
273+withEventWriterT :: (Semigroup w, Semigroup w', Reflex t, MonadHold t m, MonadFix m)
274+ => (w -> w')
275+ -> EventWriterT t w m a
276+ -> EventWriterT t w' m a
277+withEventWriterT f ew = do
278+ (r, e) <- lift $ do
279+ (r, e) <- runEventWriterT ew
280+ let e' = fmap f e
281+ return (r, e')
282+ tellEvent e
283+ return r