Skip to content

Instantly share code, notes, and snippets.

@srid
Created January 27, 2021 23:36
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 srid/a7e677fca4fef7c2923588459899b6db to your computer and use it in GitHub Desktop.
Save srid/a7e677fca4fef7c2923588459899b6db to your computer and use it in GitHub Desktop.
-- | Like `unsafeMapIncremental` but the patch function also takes the old
-- target.
unsafeMapIncrementalWithOldValue ::
(Reflex t, Patch p, Patch p') =>
(PatchTarget p -> PatchTarget p') ->
(PatchTarget p -> p -> p') ->
Incremental t p ->
Incremental t p'
unsafeMapIncrementalWithOldValue f g x =
let x0 = currentIncremental x
xE = updatedIncremental x
in unsafeBuildIncremental (f <$> sample x0) $ uncurry g <$> attach x0 xE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment