33

I've spent the better part of my morning and afternoon playing around with GUI frameworks in Haskell, as I need some visualization and interaction capabilities and I'm not in love with writing my core functionality in Haskell then piping out to a front end written in another GUI; I'd prefer to do it all from one language. The better part of that better part has been spent compiling and patching source code, or Googling obscure compilation errors.

I've spent plenty of time reading SO questions, plenty of time on haskell.org, and plenty of time reading documentation. What I've encountered is a very large swath of outdated or poorly documented information. I can boil it down to these three things:

  1. A glut of options built on top of Gtk+ bindings. I don't care for Gtk+ very much, mostly because I find it to be quite unpleasant to look at, especially on OS X. Griping about the UI looking out of place and/or just plain ugly might seem silly, but that's important to me. Especially if I want other people to utilize any of the programs that I create.

  2. wxHaskell, which is stable and incredibly easy to install but many of the existing tutorials seem to be for wx-0.1x and the conventions for bridging the wxWidgets 2.9.x docs to wx-0.90.x are very very spotty and hard to grok, when they even exist.

  3. qtHaskell, which seems to be mostly abandoned (correct me if I'm wrong), only compiles with newer versions of GHC after applying a year-old patch, and spits out a massive amount of warnings that indicate they will soon become compile errors in newer versions of GHC.

In effect, I'm looking for Haskell's answer to Java's Swing; a library that is robust, maintained, well documented, easy to get started with, makes an attempt to be native in look and feel, can keep up with GHC's development pace, and not at high risk for abandonment. This seems to be exactly zero GUI frameworks, but then it seems that most of the "official" resources/wikis/pages/docs related to GUI frameworks are woefully unmaintained so I decided to turn to the community to see if there was something I just wasn't finding. I'm not terribly worried about the framework being cross platform, just so long as it works on modern versions of OS X.

To reiterate, I'm not really looking for someone to send me a link to haskell.org or the WikiBook. I've been there, and I didn't like what I saw. Most of the information there is just so out of date that it only creates more work, not less.

I realize that my "demands" are a little extreme, especially for a language with a smaller community like Haskell, but I was hoping that someone out there could be of assistance to me. In the mean time, I intend to simply try and ride out wxHaskell or qtHaskell until I succeed or die.

I hope I'm not coming across as gruff or frazzled.

Justin
  • 24,288
  • 12
  • 92
  • 142
Doug Stephen
  • 7,181
  • 1
  • 38
  • 46
  • 2
    If I could upvote you 50 times I would. My experience in general with a lot of the neat languages is that they lack stuff like good tools for GUIs. Like you point out, that's what gets your programs used, so it's kind of a big deal. I just gave up and treat Haskell like a neat tool for experimental coding, but nothing I could do any real work in. I'd LOVE to be proven wrong. – RonaldBarzell Dec 15 '12 at 00:10
  • 1
    Perhaps it's because people don't know how to get widget toolkits right. Not just for functional languages, but in general. Personally, I think popular ideas about GUIs have hardly progressed since the '80s, and the best way to fix it is to start by abandoning legacy notions. Let's start with widgets. –  Dec 15 '12 at 00:24
  • @Tinctorius: This is intriguing. What did you have in mind? – RonaldBarzell Dec 15 '12 at 00:26
  • 1
    I totally sympathize, but... is this a really question? – jberryman Dec 15 '12 at 02:33
  • @jberryman The title of the post was originally a question, but it was edited by the community to be turned in to the context-free clause that you see here now. That said, feel free to turn it in to community wiki if you want. I don't really need the rep. I'm just genuinely curious. – Doug Stephen Dec 15 '12 at 02:36
  • Have you tried using the [ige-mac-integration package](http://hackage.haskell.org/package/ige-mac-integration-0.0.0.2) for GTK? – user1891025 Dec 15 '12 at 02:58
  • Have you seen [Gtk-OSX](http://www.gtk.org/download/macos.php)? – Daniel Wagner Dec 15 '12 at 04:17
  • @user1161318 A more data-centric view. Widgets can be used as so many things. You can use a button for too many things: transaction control (OK, Cancel), editing collections (Add, Remove, Edit), collapsing/expanding uncommon options (Advanced), and they can even be used as sort of a checkbox (toggling between normal and depressed state). Besides that, you should be able to generate certain user interfaces from the scheme of data alone, so creating a UI for that is a violation of "don't repeat yourself". Think about dialogs for settings and preferences, for instance. –  Dec 15 '12 at 09:53
  • @Tinctorius: This sounds similar to the "Naked Objects" approach. I would love to see something like this be the norm, but in so many cases, we're told what GUIs to implement and can't rely on a derived one :( – RonaldBarzell Dec 15 '12 at 17:54

3 Answers3

4

wxHaskell is good, yes, and my go-to GUI middle level library. I admit there's been a focus on updating the code before the docs in the new version.

For modern, functional-reactive-programming fun stuff on top of it I gor for reactive banana, which is actively maintained, and has the added benefit that Heinrich Apfelmus himself may well turn up here to answer your questions.

Community
  • 1
  • 1
AndrewC
  • 32,300
  • 7
  • 79
  • 115
  • 1
    I've actually been looking at FRP in general for a while, because I may do my senior thesis on how functional programming, specifically FRP, can be used in simulation environments to improve dev productivity and retain decent performance (or improved via trivial concurrency). I'm going to (attempt) an implementation of Featherstone's Articulated Body solver in Haskell. Developing some reactive GUI's might be a good place to cut my teeth. – Doug Stephen Dec 18 '12 at 18:36
  • Sounds interesting. Have fun! – AndrewC Dec 19 '12 at 02:09
4

Threepenny-gui is the most recent contender in the space of Haskell GUI libraries.

Its main selling point is that it is very easy to install, because it uses the web browser as a display. It's also easy to get started with.

On the other hand, it doesn't even attempt to have a native look and feel – the UI is built solely on HTML. (This may change in the future, as we have the option of using XUL). Also, the API is still very much in flux, so be prepared that new major versions of the library are likely to break backwards compatibility. (On the other hand, this means that it's actively developed. :-))

(Disclosure: I'm the author / maintainer of the threepenny-gui package.)

Heinrich Apfelmus
  • 11,034
  • 1
  • 39
  • 67
3

I feel your pain; this answer is an attempt to provide some alternatives that may be good enough and perhaps help you with your search.

First, there is a language called Concurrent Clean. It is supposed to be similar to Haskell, has GUI support and is meant for writing real-world applications. It differs in some respects; for instance, its I/O is based on unique types rather than Monads, which as far as I'm concerned, is a good thing :). Here is a link: http://wiki.clean.cs.ru.nl/Clean

Next, I dug around for a Haskell compiled to the JVM, in the hopes that it would piggy-back on the Java libraries, ala Clojure. No dice. What I did find was a SO thread discussing the lack and the challenges thereof: Haskell on JVM?

From that thread however, two other options were brought up. One is Frege: http://code.google.com/p/frege/

The other is CAL: https://github.com/levans/Open-Quark

There's also work on functional reactive programming in Haskell. It's supposed to enable things like GUIs, although whether or not you'll actually get a GUI out of it is another matter: http://www.haskell.org/haskellwiki/Functional_Reactive_Programming

It's sad. Here we have the JVM and .NET and yet zilch for Haskell. It's worse than that; .NET has shown an alarming tendency to ditch promising implementations. Whatever happened to IronScheme, IronLisp and IronHaskell? All dead as far as I can tell.

Not good :(

Community
  • 1
  • 1
RonaldBarzell
  • 3,822
  • 1
  • 16
  • 23
  • Frege actually looks really interesting. They note on the Google code page that they have moved to GitHub, and upon browsing their GH repo they state that they are "more or less" Haskell 2010 on the JVM. Differences outlined here: https://github.com/Frege/frege/wiki/Differences-between-Frege-and-Haskell Frege also includes an Eclipse plugin. This is nice, because I'm a Java dev by day and Eclipse is my IDE of choice. All in all, this seems to be a good find. Thanks! – Doug Stephen Dec 15 '12 at 02:21
  • @DougStephen Keep in mind, though, that Frege is quite new and you may miss one thing or another, especially with regards to libraries. Feel free to contact the developers through google groups or use the frege tag here on SO. – Ingo Dec 18 '12 at 11:46