Jules Bean wrote:
[...] Unfortunately, it's not going to work. It's not going to work because some of the procedures take callbacks, and the callbacks are values of type IO (). I can see two solutions to this:
a) revert to using an IORef [...] b) write the callbacks as values of type StateT Env IO () [...]
or c) Give up any hope of clean semantics and simply use a common hack like: {-# NOINLINE myGlobalVar #-} myGlobalVar :: IORef Int myGlobalVar = unsafePerformIO (newIORef 0) My GLUT binding does it happily, as does GHC itself, just look for NOINLINE pragmas in the following files: :-] http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/libraries/GLUT/Graphics/UI... http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/libraries/GLUT/Graphics/UI... http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/ghc/compiler/HsVersions.h?... Cheers, S.