usual wxHaskell program looks like
main = do
run gui
gui = do
....
....
gui must have type IO a
, run has type IO a -> IO ()
, also there is some initialization routines in run
.
I'm tring to do following:
data AppGlobals = AG { ... some data ... }
type MApp a = StateT AppGlobals IO a
But in this case gui must have type gui :: MApp AppGlobals
. Due to it's type it becomes impossible to use usual IO monad syntax, I mean Ihave to use liftIO
every time I performing IO action.
Is there Any convinient possibility to use State monad in wxHaskell? It's not very convinient to pass state to each event handler manually.
The wxHaskell programs I've read and written just shove the state into variables.
http://wxhaskell.sourceforge.net/doc/Graphics-UI-WX-Variable.html
Here's a good overview: http://legacy.cs.uu.nl/daan/download/papers/wxhaskell.pdf
And they use start rather than run.