module LiveCoding.Gloss.PictureM
( module LiveCoding.Gloss.PictureM
, module X
) where
import Control.Monad.Trans.Class
import Control.Monad.Trans.Reader as X
import Control.Monad.Trans.Writer
import Graphics.Gloss
import Graphics.Gloss.Interface.IO.Game
import LiveCoding
type PictureT m = ReaderT [Event] (WriterT Picture m)
type PictureM = PictureT IO
runPictureT
:: Monad m
=> Cell (PictureT m) a b
-> Cell m ([Event], a) (Picture, b)
runPictureT = hoistCellOutput (fmap massageWriterOutput . runWriterT) . runReaderC'
where
massageWriterOutput :: ((b, s), pic) -> ((pic, b), s)
massageWriterOutput ((b, s), pic) = ((pic, b), s)
addPicture :: Monad m => Cell (PictureT m) Picture ()
addPicture = arrM $ lift . tell