aelve / haskell-issues

An unofficial issue tracker for all things Haskell-related
18 stars 0 forks source link

gloss should allow arbitrary MonadIOs #44

Open Gurkenglas opened 8 years ago

Gurkenglas commented 8 years ago

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.

neongreen commented 7 years ago

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