Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- subscribeWithLast :: forall a b eff.
- (b -> a -> Eff (frp :: FRP | eff) b)
- -> b
- -> Event a
- -> Eff (frp :: FRP | eff) (Eff (frp :: FRP | eff) b)
- subscribeWithLast f z evt = dropRefEff $ do
- r <- newRef z
- unsub <-
- FRP.subscribe evt
- (\e -> readRef r >>= \a -> addRefEff (f a e) >>= writeRef r)
- pure (dropRefEff (unsub *> readRef r))
- where
- dropRefEff :: forall e x. Eff (ref :: REF | e) x -> Eff e x
- dropRefEff = unsafeCoerceEff
- addRefEff :: forall e x. Eff e x -> Eff (ref :: REF | e) x
- addRefEff = unsafeCoerceEff
- --
Add Comment
Please, Sign In to add comment