Where are the functional gui users?
There has been a lot of research into ways of creating guis in a functional language. There is libr开发者_如何学Caries 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?
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:
As before, there is also Flapjax, a JavaScript library for FRP in the web browser.
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.)
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.
精彩评论