
I took a few minutes (5) to implement the Haskell GUI example in HTk. Code attached. Forgive me for boasting but it seems clearer, simpler and shorter than any other of the examples codings on John Meacham's website. The closest competitor seems to be GIO. This code should work (I haven't tested it) on any of Windows, Linux, Solaris and FreeBSD, all of which we support. {- "Goodbye" demo as discussed on the Haskell mailing list. Specification: pops up a window saying "Hello World" and presenting a button saying "Bye". Clicking the button once changes the message to "Goodbye"; clicking it a second time causes the program to quit. -} module Main where import Computation import Events import HTk main = do mainWin <- initHTk [text "Hello World"] label <- newLabel mainWin [text "Hello World"] button <- newButton mainWin [text "Bye"] pack label [] pack button [] buttonClicked <- clicked button sync buttonClicked label # text "Goodbye" sync buttonClicked destroy mainWin

On Tue, 04 Mar 2003 20:23:49 +0100, George Russell
Forgive me for boasting but it seems clearer, simpler and shorter than any other of the examples codings on John Meacham's website.
That is just because you are used to it ;-)
The closest competitor seems to be GIO.
I am flattered but I still view GIO as an *experiment* to get a feel of how a medium-level GUI API should look like, so it is not nearly a competitor to a real library. Regards, Daan. btw. Maybe you should make the objects the last argument of instance functions. That way, you can use an object oriented style of programming (if you like that): infixr 0 # -- matches nicely with ($) (#) :: self -> (self -> a) -> a self # f = f self main = do mainWin <-initHTk [text "Hello World"] label <-mainWin # newLabel [text "Hello World"] button <-mainWin # newButton [text "Bye"] ...

Daan Leijen
btw. Maybe you should make the objects the last argument of instance functions. That way, you can use an object oriented style of programming (if you like that):
infixr 0 # -- matches nicely with ($)
(#) :: self -> (self -> a) -> a self # f = f self
FWIW we had (#) in gtk2hs for a while, but in the end it didn't seem so useful, so it was removed Jens
participants (3)
-
Daan Leijen
-
George Russell
-
Jens Petersen