Skip to content

Instantly share code, notes, and snippets.

@rahcola
Forked from anonymous/gist:2314578
Created April 5, 2012 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahcola/2314660 to your computer and use it in GitHub Desktop.
Save rahcola/2314660 to your computer and use it in GitHub Desktop.
module Kuulaskuri (luo, monesko, seuraava) where
import Data.IORef
newtype Kuulaskuri = Kuulaskuri (IORef Int)
luo :: IO Kuulaskuri
luo = do
c <- newIORef 1
return $ Kuulaskuri c
monesko :: Kuulaskuri -> IO Int
monesko (Kuulaskuri r) = readIORef r
seuraava :: Kuulaskuri -> IO ()
seuraava (Kuulaskuri r) = modifyIORef r $ \kuu -> ((kuu `mod` 12) + 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment