turion / rhine

Haskell Functional Reactive Programming framework with type-level clocks
http://hackage.haskell.org/package/rhine
121 stars 21 forks source link

GlossEventClockIO #189

Closed reubenharry closed 1 year ago

reubenharry commented 1 year ago

I notice that time doesn't progress with this clock, in the sense that sinceLastS seems to always output 0. Is this intended, and if so, is there a way I can still get the time?

(For context, I want to write a rhine-bayes example with the green dot's position being given by the user's cursor)

turion commented 1 year ago

Ah, this is a nasty bug. Can you add a GlossSimClockIO to your Rhine somewhere? That should work around it for a moment.

turion commented 1 year ago

Can you have a look whether rhine-gloss at https://github.com/turion/rhine/pull/190 fixes your example?

reubenharry commented 1 year ago

Thanks! This is a bit of a basic question, but what's the best way of using #190? That is, if I clone and build that PR, how do I then import that version of Rhine in my rhine-bayes-examples repo?

turion commented 1 year ago

Depends on whether you use stack or cabal. (I recommend cabal because it seems that stack doesn't see much maintenance anymore.) I think you use stack. There you can specify a git repository and commit to pin a dependency to a specific version: https://docs.haskellstack.org/en/stable/pantry/#git-and-mercurial-repositories. That part can be removed once I've released a new version.

reubenharry commented 1 year ago

@turion Somewhat relatedly, do you know if there's a minimal example anywhere of how I can combine a GlossEventClock in parallel with another clock, so that I can interact with gloss (e.g. by mouse movement) but not have the simulation pause when there's no input?

turion commented 1 year ago

Yes, here: https://github.com/turion/rhine/blob/3bae3ddfa1ee70b8487e214f09a80c75b34f7398/rhine-gloss/Main.hs#L37

turion commented 1 year ago

I'm assuming that this is fixed on latest master. Does that work for you? If not feel free to reopen.

reubenharry commented 1 year ago

Yes, fixed!