Skip to content

Instantly share code, notes, and snippets.

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