Let's start with a simple example, the `hello, world' program, which just prints out a string and exits. Using Haskell (version 1.3), the program looks like this:
module Main(main) where --putStr :: String -> IO () main :: IO () main = putStr "Hello, world!\n" >> return ()
The entry point to a Haskell program is main, an I/O action to execute. The above main consist of the action putStr, which just prints its argument string to standard output:
sof@marcus% ghc -fhaskell-1.3 hello.hs -o hello sof@marcus% ./hello Hello,world! sof@marcus%
To a create a graphical user interface version of hello, world, requires slightly more work, since we have to open up a window for the string to be displayed in. The Haggis versions looks like this
module Main(main) where
import Haggis
main =
wopen ["*title: Hello"]
(label "Hello, World") >>
return ()

The wopen action opens up a window containing a label displaying Hello, World. The label is one the user interface abstraction that comes with Haggis, displaying static text strings. Think of the wopen function as opening a new I/O virtual device in much the same manner as openFile opens a file device for reading or writing. Instead of specifying the device via a filename string, wopen uses a description of a user interface to open up a window containing an interactive, graphical virtual device. In our Hello, World example, the description of the virtual I/O device is simply a label.
The first argument to wopen is a list of style options, like the label to decorate the window with.