[Haskell-cafe] mixing wxhaskell state and file io

Martin DeMello martindemello at gmail.com
Sun Feb 4 14:03:27 EST 2007


I'm having a lot of trouble mixing file io and wxhaskell's
varCreate/Get/Set functions. I have functions

readWords :: String -> IO WordMap
wordGrid :: WordMap -> Layout

And within my GUI code, the following compiles (ignores the variable,
basically):

 words  <- varCreate (do {w <- readWords "words"; return w})
 wGrid  <- do w <- readWords "words"
                    return $ wordGrid w

but I can't get the following (noncompiling code, but it shows what
I'm trying to do) working:

 wGrid  <- do w <- varGet words
                    return $ wordGrid w

Could someone give me a minimal example of reading in a list of words
from a file, binding a wxHaskell variable to the list, and then
mapping some GUI code over it?

(Also, I'm making the base assumption that varSet and varGet are
wxHaskell's analogue of the State monad - should I be looking at using
StateT instead?)

martin


More information about the Haskell-Cafe mailing list