How to use reactive banana with Gtk2Hs?
Asked Answered
D

0

8

I am trying to get some experience with reactive-banana, accord to its website, it should support GTK. I was wondering if there is any tutorial/introductory material on how to do that?

I read here in SO that there is a jaek project, but I am more looking for a minimal example for using reactive-banana with gtk2hs (gtk3 from hackage), as I have no prior experience with FRP or reactive-banana.

Also, I tried many many times to get reactive-banana-wx work on Windows/MinGW. Even though I was able to eventually get wxHaskell to install, there were run-time errors up-front (https://stackoverflow.com/questions/23367950/wxc-segfault-in-wxhaskell). I guess I couldn't get wxHaskell to work properly unless I downgrade everything to 2010 or earlier, as there have been no instructions after that on how to make wxHaskell work on Windows, only questions.

I tried installing Gtk2Hs today. Even with gtk3, it was a breeze. That makes me wonder if there is good material for beginners on this route (i.e. reactive-banana + gtk2Hs).

Thanks,

Dayfly answered 30/4, 2014 at 17:4 Comment(5)
It might have bitrotted by now, and it may not be a great example, but I used reactive-banana and gtk2hs to do a demo of FRP about a year ago called Functionally Reactive Solar System.Default
If you want to take inspiration from jaek, start from Jaek.UI.FrpHandlers, see how GTK events are wired in in functions like clickEvents', and then follow on to Jaek.UI.FrpTypes, where you can find glue code using newAddHandler and fromAddHandler (e.g. in event1). It uses a rather old version of reactive-banana, but the key things still hold.Annikaanniken
Thanks for the hints. I will read your examples later when I now more about gtk. Honestly, I don't even know that much about gtk programming. I have some experience in wx programming. So is there such a thing as programming with reactive-banana without worrying about whether it's hooked to wx or gtk? Or is it completely different if you go with wx and with gtk (even if somebody come up with a reactive-banana-gtk someday).Dayfly
The only thing that will be different is the glue code you need to convert GTK/wx events into reactive-banana ones. Once you have a eClickOK :: Reactive.Banana.Event t () you can wire it into your event network without caring whether it came from GTK or wx or Threepenny and so forth. So it can be done as long as the glue code is kept into a separate, self-contained module.Annikaanniken
When I needed a binding to gtk I used github.com/conklech/reactive-banana-gtk - again, not sure how up to date this is.Default

© 2022 - 2024 — McMap. All rights reserved.