zu www.bildungsgueter.de Table of Section Contentss

Preface


For the beginner, it is not easy to program a GUI with Haskell. There are several difficulties to overcome. One difficulty is to understand how Gtk-3 is embedded into Haskell. It is of course done with monads, but monads are a rich topic in its own right. A second difficulty arises from the fact that Haskell allows coding in very different styles: For example, you can code event handlers as lambda expressions or as anonymous functions or as named functions. The types of lambda expressions and anonymous functions are inferred; the type of a named function has to be specified. ...

This tutorial explains the use of Haskell with Gtk-3. The differences between the Haskell interfaces to Gtk-2 and to Gtk-3 are substantial, also the approach for Haskell to Gtk is a bit different from what you may know from languages as C or Ada.

A final word about the screenshots:

Gtk-3 uses themes to specify how widgets are drawn. It is therefore possible that some widgets are drawn differently on your computer. This should not be a problem, but you should bear in mind that several design variants of Gtk are in use.


There is a noteworthy peculiarity:

The package libghc-gtk3-dev uses the Gtk-3 framework, but it keeps the application programming interface of Gtk-2. As a consequence, there is no equivalent for statements like

hBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);

or

gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, adjustment);

Instead, you have to use the constructors of Gtk-2, which mention the orientation of the item to be constructed in the constructor's name.


Table of Section Contents