Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oliver-batchelor/8e4af18c4a13ada54e1f86dfdab85b6b to your computer and use it in GitHub Desktop.
Save oliver-batchelor/8e4af18c4a13ada54e1f86dfdab85b6b to your computer and use it in GitHub Desktop.
untilE :: (Reflex t, MonadHold t m, MonadFix m) => (a -> Bool) -> Event t a -> m (Event t a)
untilE f e = do
last <- headE (ffilter f e)
switchHold e (never <$ last)
holdDynUntil :: (Reflex t, MonadHold t m, MonadFix m) => (a -> Bool) -> Dynamic t a -> m (Dynamic t a)
holdDynUntil f d = buildDynamic (sample (current d)) =<< untilE f (updated d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment