[Haskell] how to write an interactive program ? gui library
to use ?
heringtonlacey at mindspring.com
Sat Feb 25 13:34:51 EST 2006
At 7:31 PM +0100 2/24/06, minh thu wrote:
>I'd like to know how can I implement an interactive program (an
>editor) in haskell where some "things" have to be updated.
>The "things" can be text in a word processor, or a pixel array in a
>2d graphics editor, and so on.
>Have I to pass the state (the "things") explicitely in the arguments
>of the main loop (a recursive function) ?
>Sorry if it's stupid...
No, it's not a stupid question at all...
Essentially, the answer is "yes", the state needs to be passed around
(neglecting hackery to simulate global variables that is better
avoided). However, this can be made convenient by using a monad.
You define a monad which is based on IO and carries your state
(something like StateT YourState IO a; see
More information about the Haskell