-
-
Save rahcola/2314660 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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