Recommended Haskell GUI library?

What are the recommended libraries to build quick-and-dirty GUIs in Haskell nowadays? The suggestions on the Haskell wiki look outdated. Don’t really care about the look-and-feel as long as it gives me some basic controls like buttons, textboxes and a grid.

I have used wxHaskell in the past and am looking for something like it. I did not manage to get wxHaskell working with current GHC yet. Did anyone have success with it or any other library recently?

My requirements:

  • Should work on Windows. In worst-case I could run it under WSL2, but prefer something native.
  • Medium-level library like wxHaskell. I’d prefer it not be just a bunch of low-level bindings to Win32/GTK/Qt/WPF/… or something opinionated like FRP. If that is my only option, though, I’ll probably take it.
  • Native desktop programming model. If it has to run in the browser than it should give me a programming model similar to wxHaskell.
5 Likes

I’ve never written a GUI app in Haskell before, but if I had the need I’d probably try monomer first.

6 Likes

As the field is not very mature, you will have to do some amount of pioneering yourself.
I highly recommend Monomer, but keep in mind that the story is not like Java’s or Python’s.

3 Likes

I used fltkhs which worked.

I think GTK is quite well documented. The Real World Haskell book has an example podcast app and it’s used for ThreadScope, for instance.

2 Likes

I’d also rather try Monomer. Looks like a nice library with native bindings to OpenGL.

1 Like

Another option is https://hackage.haskell.org/package/dear-imgui, which provides Haskell bindings to GitHub - ocornut/imgui: Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies. This is particularly well suited to quick and dirty - Dear ImGui was built to aid building debug UIs for game development

3 Likes

Touting my own horn: Threepenny-GUI is a GUI library uses the web browser as a display. Its main goal is to be dead-simple to install.

4 Likes

I can recommend threepenny-gui as working well, at least for the simple stuff I tried, and being easy to use. Also a great way to learn about functional reactive programming (optionally).

1 Like

Hey wanted to revive this because still seems relevant. Is monomer still looking like the best option? It is a heroic library but has some red flags:

  • Black-screen & crashing with no error feedback
  • Underlying C dependency is flagged as not maintained
  • Not indexed by hoogle

I’ve had some success getting it working, the design of AppModel, Events and Widgets seem really great. The examples work without crashing, but in development it crashes intermittently and seems to get worse as I add more elements & model changes. Anyone have success with monomer, some instability too? Suggestions about how to debug GL crashes? Any new options out there?

Edit: Below compiles but freezes if model batch array isn’t empty.
AddNodes b -> [Model $ model & batch .~ (b <> (model ^. batch)) ]

Edit: I think the crashing isn’t openGL but is being killed by plugin manager. Is there any way to suppress all logging out stdout that monomer is creating?

5 Likes

Probably GTK. Here you have an example: Building a GTK App With Haskell (In Under An Hour) - YouTube

There is also a good resource by Serokell: https://www.youtube.com/watch?v=k1aq8ikO-8Q

3 Likes

I got tired of mentioning the same list over and over again, so I wrote a whole article on this topic: http://bradrn.com/posts/hs-gui-libs.html.

14 Likes

A few of us have actually been working on reviving wxHaskell. This has really gained momentum in the past few weeks, largely thanks to @fgaz. Hopefully we’ll have something up on Hackage soon.

That branch is currently easy to use once the wxc system library is installed. We’ve published an AUR package for this, for anyone on Arch Linux or its derivatives, and we’re working on a Nixpkgs submission. We’d love assistance from anyone with experience with Windows distribution, as well as other solutions such as Homebrew.

14 Likes

Great to hear! I’m on Linux these days, but happy to help out with Windows to the extent that I can. My hunch is that if you can get wxc into the MSYS2 package repo, we would already be most of the way towards Windows support.

3 Likes

Thanks, that would be great!

Right now I am in love with monomer. I made a pomodoro timer for myself and it was great


I also got experience with hs-gtk. I did musicScroll with it. With gtk, the main loop is obviously outside your control and updates know too much about the app state.

With monomer, you operate on a MVC fashion more clearly. Pretty neat.

1 Like

Oddly enough, this is the problem I have with Monomer. Since it follows the so-called ‘Elm architecture’, all your state is forced to be stored in a single data structure, which effectively ends up being global to the application. For small programs this is perfectly fine, but it could cause problems for larger ones.

I did not know what the Elm architecture was when I started using monomer, but at first I also felt most of the data had to live in the same datatype. The monomer approach is to manage that via lenses and composites which are equivalent to the “zoom lens trick” for massaging state.

On my example above the work time & rest time widgets are a composite. They do not operate over the whole state, only a subpart. The parent widget can depend on that state as is nested. Those widgets themselves cannot.

Oh, this is interesting… not sure I understand the tutorial you linked, but I’ll have to look at this more fully!

I don’t have a lot of experience with GUIs in Haskell, but I liked using the gi-gtk library in the past. I used glade to design my UI rather than doing it programmatically.

I have a small example of an old cookie clicker tool I used to develop that shows gi-gtk+glade in action. You can’t really use it to play cookie clicker any more, but it’s still an example of how to use the library:

2 Likes

I tend to default to gi-gtk when I want to make a GUI in Haskell. It is indeed pretty nice… if you can tolerate GTK’s eccentricities, that it. For anything more complicated than a set of static widgets I often end up using Qt instead and writing the GUI in C++ (which itself says quite a lot about how awful GTK is to use!).

1 Like