Skip to content

Instantly share code, notes, and snippets.

@scan
Created August 17, 2012 17:04
Show Gist options
  • Save scan/3380659 to your computer and use it in GitHub Desktop.
Save scan/3380659 to your computer and use it in GitHub Desktop.
{-# LANGUAGE Arrows, NoMonomorphismRestriction #-}
module Main where
import Prelude hiding ((.), id)
import Control.Applicative
import Control.Arrow
import Control.Wire
import qualified Control.Monad as M (when)
import Control.Monad.Loops
import Control.Exception
import Graphics.UI.SDL as SDL
main = bracket_ (SDL.init [InitVideo]) SDL.quit $ do
screen <- setVideoMode 800 600 0 [DoubleBuf, HWSurface]
sess <- clockSession
let loop s w = do
ev <- unfoldWhileM (/= NoEvent) pollEvent
(v, w', s') <- stepSessionM_ s ev w
M.when v $ loop s' w'
loop sess system
system = proc ev -> do
quit <- pure False . quitEv <|> pure True -< ev
returnA -< quit
quitEv = when (elem Quit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment