Take the 2-minute tour ×

There has been a lot of research into ways of creating guis in a functional language. There is libraries for push/pull frp, arrow based frp and probably other superior research too. Many people seem to agree this is the more native way yet just about everyone seems to be using imperative binding libraries such as gtk2hs and wxhaskell. Even places recommended as good tutorials teach binding to these plain imperative libraries. Why not guis based on FRP research?

share|improve this question
Talkin of frp GUIs as superior to imperative GUIs won't get you much love. Interesting question though. –  delnan Aug 14 '10 at 10:36
possible duplicate of Is functional GUI programming possible? –  Don Stewart Aug 14 '10 at 18:16
possible duplicate of stackoverflow.com/questions/1028250/… –  Don Stewart Aug 14 '10 at 18:17
@Don it's not a dupe of the second one b'cos I wouldn't ask this without knowing the meaning and not of the first because I have actually linked to that in the question. –  Tim Matthews Aug 15 '10 at 4:13

3 Answers 3

While everyone agrees that functional reactive programming (FRP) is the way to go for implementing graphical user interface, no well-rounded library for doing so in Haskell has emerged yet. I think the main reasons are:

  • Balancing expressivity VS resource usage is difficult (space leaks, timing issues). The more expressive your FRP model, the harder it is to implement it while still guaranteeing efficiency. The design space is still being explored.
  • API convenience. FRP is well-suited for implementing functions of the form Time -> MouseInput -> Picture, but GUI platforms like GTK+ or Cocoa don't work like that, and the question is how to express the latter in FRP style without getting more complicated than the traditional style.

In other words, FRP research is not yet complete.

That being said, some practical implementations already exist, for instance Flapjax, a language that compiles to JavaScript.

In any case, nobody can stop you from implementing your own FRP library tailored for a particular purpose and greatly profit from that. Luke Palmer has done so successfully, and I'm currently trying that as well. (I'd rather waste my time with FRP than with mutable variables.)

share|improve this answer
JFYI, Flapjax can and should be used as a library, the separate language with compiler is planned to be deprecated. –  thSoft Jul 27 '11 at 17:06

Almost a year has passed since my previous answer and things have changed in the world of functional reactive programming (FRP).

  • In particular, I have created reactive-banana, a small library for FRP in Haskell. While still missing some features, it's already a great way to implement GUIs in a purely functional style, as demonstrated by a collection of examples. Here a screenshot: enter image description here

  • As before, there is also Flapjax, a JavaScript library for FRP in the web browser.

share|improve this answer
Also, Ur/Web's signal model for writing client-side that gets compiled to AJAX, is inspired by FRP - but it's not really FRP. –  Robin Green Aug 4 '11 at 11:35

Old thread, I know, but Elm (elm-lang.org) is fast becoming the hub of "real-world" FRP. It compiles down to JavaScript, and the Elm website is written in it.

share|improve this answer

Your Answer


