Created
August 4, 2015 20:41
-
-
Save saevarb/5271254022dcadb0d929 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import Control.Monad.State | |
foo :: StateT Int IO () | |
foo = do | |
get >>= \s -> liftIO . putStrLn $ "state = " ++ show s | |
iterateState | |
liftIO . putStr $ "Please enter q to quit> " | |
c <- liftIO getLine | |
unless (c == "q") foo | |
where | |
iterateState = do | |
modify (+1) | |
main :: IO () | |
main = do | |
let initialState = 3 | |
evalStateT foo initialState |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment