Haskell GUI
Friday, December 7th, 2007In the last few days I’ve been checking out some haskell GUI frameworks. This is what I found so far.
Gtk2Hs
As the name says, Gtk2Hs is a library which bases on the Gtk+ project. It supports native look’n'feel and is supported on Linux, MacOS and Windows. You can even use the glade interface builder on Linux for creating your Haskell guis.
The user interface code is implemented in one big Monad (how else?) and a hello world application looks like
import Graphics.UI.Gtk main :: IO () main = do initGUI window <- windowNew button <- buttonNew set window [ containerChild := button ] set button [ buttonLabel := "Hello World" ] onClicked button (putStrLn "Hello World") onDestroy window mainQuit widgetShowAll window mainGUI
wxHaskell
wxHaskell is a Haskell like wrapper built on top of the C++ wxWidgets framework. It runs on all major platforms as well and supports native look’n'feel. The MacOS port is available as a darcs repository.
The example.
module Main where import Graphics.UI.WX main :: IO () main = do f <- frame [text := "Hello World"] quit <- button f [text := "Quit", on command := close f] set f [layout := widget quit]
HOC
On http://hoc.sourceforge.net/ there are Objective-C bindings so it is possible to access MacOS’ Cocoa library from Haskell and build Cocoa objects from Haskell.
[Update]
Eric pointed out some mistakes.
