mikesol/purescript-hyrule

Remove fix from IsEvent?

Closed this issue · 2 comments

I'm wondering if it's a good idea to remove fix from the IsEvent class and use it only in Behaviors?

The rationale here is that fix seems to be most useful when you have a function of time that is defined in terms of itself, like a differential equation. When that happens, it is almost certainly in the form of a Behavior, as differential equations need to be continuous on the entire time domain.

Otherwise, to define an event whose output is dependent on its input, you can just use fold. If you want to do something fancy, like for example enter into a mini-loop where an event causes itself to fire several times before coming to stasis, you can make the b in fold :: (a -> b -> b) - event a -> b -> event b of type Event something and then use keepLatest to flatten the event.

Thoughts?

Sure that makes sense! Does fix even work when there are multiple subscriptions on it? It seems like it would subscribe to the downstream node multiple times idk.

I'll close this for now just because it's not clear to me yet what IsEvent should actually contain. TBH I'm not even sure a typeclass here makes sense. I'll open a new issue about that.