27

I'm just starting to look into the world of Functional Reactive Programming in Haskell, and I would like to experiment with GUI programming (with gtk, because of substantial binding) in a reactional setting.

Now, I've been looking a bit at Grapefruit, Reactive-Banana and Buster, and I would like any testament to the joy/horror of using any one or other package.

All I have is these preliminary oppinions:

  • I don't mind doing some of the binding of the FRP package to gtk myself, as I have an ambivalet feeling about the abstracted backend idea (that Grapefruit has)..

  • While I find type theory interesting, I also value simple encodings for actual programs, which seems to put grapfruit-records a bit off..

That is, unless of course some of you persuades me to think otherwise :-)

plc
  • 862
  • 7
  • 19
  • 4
    "graprefuit" and "reactive-banana"? Is there some special affinity between frp and fruit? – ben w Apr 03 '12 at 20:14
  • 1
    @benw: I believe the "banana" part is a reference to a paper with one of the most amusing titles I know: [Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire](http://research.microsoft.com/en-us/um/people/emeijer/Papers/fpca91.pdf). – hammar Apr 03 '12 at 20:23
  • 1
    @hammar: Haha, nice! Actually, I chose the name "banana" for different reasons, but I like the one mention. – Heinrich Apfelmus Apr 04 '12 at 13:21
  • possible duplicate of [What's the status of current Functional Reactive Programming implementations?](http://stackoverflow.com/questions/13341937/whats-the-status-of-current-functional-reactive-programming-implementations) – sclv Feb 28 '13 at 19:13
  • 1
    @HeinrichApfelmus Intriguing - what reasons? – AndrewC Jul 11 '13 at 10:13
  • 3
    @AndrewC It's actually a reference to the "peanut butter jelly" video. Animations are a good example for explaining the essence of FRP, and I thought that a dancing banana is the best example animation for this purpose. – Heinrich Apfelmus Jul 12 '13 at 08:49

2 Answers2

19

If you just want to use regular FRP, and stay close to the GUI framework rather than using a "pre-made" abstraction over it, reactive-banana is the most viable option, in my opinion. It's explicitly geared around binding to existing frameworks, is designed for "real-world" use (not doing anything too experimental, semantically, that could cause problems), and so on.

You can take a look at reactive-banana-wx to see how to bind an event-based framework to reactive-banana. It's very simple; I wrote a quick binding to Gtk2Hs once (lost the code now, unfortunately), and the file didn't go over 50 lines. It was almost a direct transliteration of the reactive-banana-wx code.

I would recommend against using Buster, for the simple reason that it hasn't been updated since 2009, and doesn't build on GHC 7.

Other "production-oriented" FRP frameworks are sodium (similar to reactive-banana, but it has dynamic event switching (which is coming to reactive-banana soon, but isn't in yet) and a concept of "partitions" for concurrency; however, it's just come out and hasn't seen adoption yet) and netwire (arrowised FRP, quite a different creature to reactive-banana and sodium).

ehird
  • 39,804
  • 3
  • 173
  • 180
  • 2
    update: switching is in reactive banana as of version 0.7.0.0 – AndrewC Jul 11 '13 at 10:16
  • 1
    (However, Heinrich Apfelmus is still (2013.06.20) [working on](http://stackoverflow.com/questions/15396038/dynamic-event-switching-in-reactive-banana-causes-severe-leak#comment24927049_15396038) the garbage collection of dynamic event switching, so use with caution at the moment.) – AndrewC Jul 11 '13 at 10:41
12

I've been experimenting with FRP myself and so far the only one that's worked for me is Reactive-Banana. I never looked into Grapefruit or most of the others because they were out of date and didn't seem like they were likely to be updated or supported at all. I did briefly look at netwire, but frankly all the arrow theory in it put me off and I had a lot of trouble figuring out how to do even simple things.

In contrast I've managed to get a pretty good set of bindings to SDL written in Reactive-Banana with only a few hiccups along the way. Another thing in favor of Reactive-Banana is that Heinreich is very active in the community and will often provide helpful answers when you run into problems. Just look through the various reactive-banana questions on here and you'll see he's responded to quite a few of them and he's usually very active in FRP discussions in the Haskell mailing lists.

Orclev
  • 735
  • 6
  • 16