You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found myself wanting a different event combination strategy than using merge when using EventWriterT.
Therefore I generalised the type of tellEvent to
class (Monad m, Semigroup w) => EventWriter t (f :: * -> *) w m | m -> t w where
tellEventF :: f (Event t w) -> m ()
and implementing a running function which returned a list of the wrapped events rather than
always combining them with merge.
-- | Run a 'EventWriterT' action.
runEventWriterTWithComb :: forall t f m a r. (Reflex t, Monad m)
=> EventWriterT t f r m a
-> m (a, [f (Event t r)])
runEventWriterTWithComb (EventWriterT a) = do
(result, requests) <- runStateT a $ EventWriterState (-1) []
let combineResults :: DMap (TellId r) (Compose f (Event t)) -> [f (Event t r)]
combineResults =
DMap.foldlWithKey (\vs tid (Compose v) -> withTellIdRefl tid $ v : vs) [] -- This is where we finally reverse the DMap to get things in the correct order
let e = combineResults $ DMap.fromDistinctAscList $ _eventWriterState_told requests
return (result, e)
I found myself wanting a different event combination strategy than using
merge
when usingEventWriterT
.Therefore I generalised the type of
tellEvent
toand implementing a running function which returned a list of the wrapped events rather than
always combining them with
merge
.mpickering@cf216f3
The text was updated successfully, but these errors were encountered: