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.
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.
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).
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?
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.
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.
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.
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.
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:
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!).