Let’s say I have the following type:
type diff = Foo of int | Bar of string
which represents diff updates of a complex data structure. I have another object,
baz : int, that is listening to the diff updates and updates to its values based on the diff.
baz updates with the following rule
function | Foo x -> baz := !baz + x | Bar x -> baz := !baz + (String.length x)
The update that
baz needs to perform is a fold update whenever
diff changes. I was looking at the Incremental API for this type fold update. However, there is no clear way to do this without exposing mutation. Is there a way to do this without exposing any mutation?