Skip to content

Instantly share code, notes, and snippets.

@timjb
Last active September 12, 2015 10:58
Show Gist options
  • Save timjb/7dca910fa730012a4b6f to your computer and use it in GitHub Desktop.
Save timjb/7dca910fa730012a4b6f to your computer and use it in GitHub Desktop.
{-# LANGUAGE TypeOperators, ScopedTypeVariables #-}
import Prelude hiding (until)
import Control.Monad hiding (when)
import Control.Applicative hiding (empty)
import Data.Set hiding (filter,fold, foldl,map)
import Control.FRPNow
import Control.FRPNow.Gloss
import Graphics.Gloss.Interface.Pure.Game
picture :: Int -> Picture
picture numCurry = Text $ show numCurry
mainFRP :: Behavior Float -> EvStream GEvent -> Behavior (Behavior Picture)
mainFRP time evs = mainBehavior 0
where mainBehavior :: Int -> Behavior (Behavior Picture)
mainBehavior n = do
pressPlusEv <- next $ void $ filterEs isPressPlus evs
nextMain <- snapshot (mainBehavior (n+1)) pressPlusEv
pure $ picture n `step` nextMain
isPressPlus (EventKey (Char '+') Down _ _) = True
isPressPlus _ = False
main = runNowGlossPure (InWindow "CurryCounter" (800, 600) (10, 10)) white 60 mainFRP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment