Top Level TWI's again was Re: [Haskell] Re: Parameterized Show

Axel Simon A.Simon at
Tue Nov 23 02:36:44 EST 2004

On Mon, 2004-11-22 at 23:34, John Velman wrote:

> In a nutshell:
>    I want to use the old value of a tag to compute the new value, in a
>    callback, 
>    I want to access the tag from other callbacks, and
>    I want to the value to a mutable list from within the callback.
> I'd certainly be interested in doing without global variables, and would
> appreciate any advice.

For GUI programming you don't need global variables. You can partially
apply all those values to the callback that are necessary. In
particular, those values can be MVars or IORefs which are like pointers
to a value (i.e. you can modify them). For example to draw a bit of

  canvas <- drawingAreaNew
  text <- canvas `widgetCreateLayout` "Hello World."
  canvas `onExpose` updateCanvas canvas text

where the function updateCanvas takes 3 arguments:

updateCanvas :: DrawingArea -> PangoLayout -> Event -> IO Bool
updateCanvas canvas text (Expose { area=rect }) = do

> (By the way, I'm using Linux, and so far it looks like HTk is my choice for
> the GUI interface.)

I don't know if HTk is still maintained. The most popular GUI toolkit is
wxHaskell now; if you're only developing on Unix then gtk2hs might be a


More information about the Haskell mailing list