Cookbook/Graphical user interfaces

From HaskellWiki
< Cookbook
Revision as of 11:34, 9 July 2009 by Lenny222 (talk | contribs) (smaller headlines)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


wxHaskell is a portable and native GUI library for Haskell based on the wxWidgets Library.

Hello World example:

module Main where
import Graphics.UI.WX

main :: IO ()
  = start hello

hello :: IO ()
  = do f    <- frame    [text := "Hello!"]
       quit <- button f [text := "Quit", on command := close f]
       set f [layout := widget quit]

This code was taken from "a quick start with wxHaskell".


Gtk2Hs is a GUI Library for Haskell based on GTK. Gtk2Hs Tutorial.

Hello world example:

import Graphics.UI.Gtk

main :: IO ()
main = do
    w <- windowNew
    b <- buttonNew
    set b [buttonLabel := "Quit"]
    onClicked b $ widgetDestroy w
    set w [windowTitle := "Hello", containerBorderWidth := 10]
    containerAdd w b
    onDestroy w mainQuit
    widgetShowAll w

For more examples, see: Applications and libraries/Games


HOpenGL is a Haskell binding for the OpenGL graphics API (GL 1.2.1 / GLU 1.3) and the portable OpenGL utility toolkit GLUT. There is a Haskell OpenGL Tetris program at [[1]] by Jim.

See also: Applications and libraries/Games


There are some Haskell bindings to SDL at Hackage.