Skip to content

Fix incorrect use of unsafeBuildIncremental in runQueryT#530

Open
parenthetical wants to merge 1 commit intoreflex-frp:developfrom
parenthetical:requester-bug
Open

Fix incorrect use of unsafeBuildIncremental in runQueryT#530
parenthetical wants to merge 1 commit intoreflex-frp:developfrom
parenthetical:requester-bug

Conversation

@parenthetical
Copy link
Copy Markdown
Contributor

A small issue I discovered while writing alternative implementations: runQueryT violates the unsafeBuildIncremental contract. The behavior being sampled only reflects the initial value, not the value at any time:

 runQueryT (QueryT a) qr = do
   ((r, bs), es) <- runReaderT (runEventWriterT (runStateT a mempty)) qr
-  return (r, unsafeBuildIncremental (foldlM (\b c -> (b <>) <$> sample c) mempty bs) (fmapCheap AdditivePatch es))
+  v0 <- foldlM (\b c -> (b <>) <$> sample c) mempty bs
+  inc <- holdIncremental v0 (fmapCheap AdditivePatch es)
+  return (r, inc)

This just happened to work because the unsafe-built incremental tends to be forced immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant