Name: Anonymous 2010-04-25 15:36
I've been learning Haskell for more than a month now and I did not have too much trouble understanding monads in general, but the state monad is giving me a headache. I think I have a vague idea how it works, but I am still unable to do the following:
How the hell do I update a list of points in click event handler and draw those points in onPaint? My every attempt failed either with compiler errors or list not updating.
data Point = Point {
ptX :: Float,
ptY :: Float }
main = do
-- create window and register some event handlers
mainGUI
onWndClick ev do
let x = eventX ev
let y = eventY ev
-- put this point into list
onPaint canvas = do
-- draw the points from the listHow the hell do I update a list of points in click event handler and draw those points in onPaint? My every attempt failed either with compiler errors or list not updating.