Comments (5)
Question: is the Graph data structure meant to be a DAG?
Yes, it's meant to be a DAG.
If so, perhaps
insertEdge
should just call error instead of making a cycle?
That would be nice — but we would have to detect that there is a cycle. 😅 This can be done with a depth first search, but that is an expensive operation in that it needs to visit all the vertices on the putative cycle. I'm currently not aware of an algorithm that keeps track of the transitive closure and can do incremental updates that are faster than this. 🤔
That said, it may be possible to detect the cycle while the Event
is turned into a Pulse
, as this process does involve a depth first search of sorts anyway.
from reactive-banana.
Hm. Let's digest the call to doStep
. If onStart
does not have an occurrence, then the state change for onStateChange
should be
(Nothing, ["Hello"]) → (Just "Hello", [])
but this invalidates the assumption that onStart
does not occur. On the other hand, if both onStart
and onState
have an occurrence, then the state change for onStateChange
should be
(Nothing, ["Hello"]) → (Nothing, ["Won't see me!"])
and this invalidates the condition for onStart
to occur.
This looks like a classic let x = not x
paradox and I agree that it should be outlawed. It's probably possible to shrink this example to use only Bool
, that would make for a useful unit test.
How does the model implementation behave for this example?
Internally, it seems that the Reactive.Banana.Prim.Plumbing.dependOn
function does not notice when a cycle of event dependencies is being created.
from reactive-banana.
Question: is the Graph data structure meant to be a DAG? Its docs only mention being directed, but seems to have an API that relies on it being acyclic, too (e.g. walkSuccessors
claims to visit a vertex only after all of its predecessors are visited).
If so, perhaps insertEdge
should just call error
instead of making a cycle? (And would that fix this issue?)
from reactive-banana.
That said, it may be possible to detect the cycle while the Event is turned into a Pulse, as this process does involve a depth first search of sorts anyway.
@HeinrichApfelmus could you provide some guidance on where in the code one might find an Event
turning into a Pulse
, with this depth-first-search-of-sorts nearby? I'm interested in tackling this issue, to the extent that it can be tackled, but (as usual) the code is all a little over my head 😃
from reactive-banana.
@HeinrichApfelmus could you provide some guidance on where in the code one might find an Event turning into a Pulse, with this depth-first-search-of-sorts nearby?
That's a tough one. 🤔 The best I can do in a pinch is to point you to the documentation of observable sharing in the design document: https://github.com/HeinrichApfelmus/reactive-banana/blob/master/reactive-banana/doc/design/design.md .
The issue is that the Cache
type supports arbitrary recursion and cannot distinguish between Event → Behavior → Event
(allowed) and Event → Event
(disallowed).
If you look at the implementation of Reactive.Banana.Prim.High.Combinators.mapE
and friends, you will find the function liftCached1
which eventually results in a call to Reactive.Banana.Prim.High.Cached.cache
. This functions pretends that the monadic action that creates the Pulse
will succeed, and caches its value for recursive use. This is necessary to handle the case of a Event → Behavior → Event
recursion, but unfortunately, it also yields a result when recursing Event → Event
; the problem is that this result is now semantically unsound.
The only viable solution is to reify the issue in the structure of the code somehow. In other words, one would probably need two distinct Cache
types — one for Event
, one for Behavior
— in such a way that mutual recursion between them is allowed, but recursion within a type is forbidden.
from reactive-banana.
Related Issues (20)
- `reactive-banana` can't be compiled on GHC 9.2 HOT 2
- I created a Matrix channel HOT 8
- An interesting `Applicative`-ish way of combining `Event`s HOT 4
- Add `MonadMoment` instances for all monad transformers in `transformers` HOT 1
- Release 1.3.0.0 HOT 3
- Join Stackage HOT 4
- `Behavior` constantly re-evaluating when caching is expected HOT 4
- Unexpected memory growth HOT 6
- Event handler not seeing early events. HOT 12
- `Behavior`s can hold onto more memory than they need to HOT 2
- Memory leak with dynamic behavior switching HOT 16
- Gloss GUI events not responding HOT 5
- Idea: add a combinator to track when a behavior is a different value HOT 14
- Call `unregister` for garbage collected events made by `AddHandler`. HOT 9
- Discrepancy in model and implementation HOT 15
- Optimize representation of Latch HOT 1
- Not compatible with these-1.2 (disallowed) HOT 2
- Simultaneous events can have undefined behavior within execute HOT 2
- source-code formatter? HOT 2
- Accept deepseq-1.5 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactive-banana.