At 7:31 PM +0100 2/24/06, minh thu wrote:
Hi all,
1/
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
http://www.haskell.org/ghc/docs/latest/html/libraries/mtl/Control-Monad-State.html).
_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell