haskell-issues icon indicating copy to clipboard operation
haskell-issues copied to clipboard

gloss should allow arbitrary MonadIOs

Open Gurkenglas opened this issue 8 years ago • 1 comments

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.

Gurkenglas avatar Aug 24 '16 01:08 Gurkenglas

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 in m are discarded. It is run only for its side-effects in IO.

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).

neongreen avatar Jan 01 '17 22:01 neongreen