haskell-issues
haskell-issues copied to clipboard
gloss should allow arbitrary MonadIOs
As an alternative to playIO :: Display -> Color -> Int -> world -> (world -> Picture) -> (Event -> world -> world) -> (Float -> World -> World) -> IO ()
, playM :: MonadIO m => Display -> Color -> m Picture -> (Event -> m ()) -> (Float -> m ()) -> m ()
would give the user more power.
Gloss uses GLUT callbacks, so you'd likely have to do it with monad-control, and I'm not sure it'd be useful. E.g. fork
(which could be thought of as the simplest function that takes an IO ()
callback) can't be generalised properly: http://hackage.haskell.org/package/lifted-base-0.2.3.8/docs/Control-Concurrent-Lifted.html#v:fork
Note that, while the forked computation
m ()
has access to the captured state, all its side-effects inm
are discarded. It is run only for its side-effects inIO
.
Similarly, in Gloss's case this would only really be usable for e.g m = Reader
(but then it's easy to lift Reader
into IO
directly).