Created
December 4, 2017 09:33
-
-
Save n4to4/dda8073573ff3637ac86fd6c3b817957 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
module Main where | |
import Control.Monad.Reader | |
import Control.Monad.State | |
r1 :: IO () | |
r1 = flip runReaderT 1 $ do | |
ask >>= liftIO . print | |
local (+1) $ ask >>= liftIO . print | |
ask >>= liftIO . print | |
r2 :: (MonadIO m) => StateT Int m ((), Int) | |
r2 = flip runStateT 1 $ do | |
get >>= liftIO . print | |
modify (+1) >> (get >>= liftIO . print) | |
get >>= liftIO . print | |
main :: IO () | |
main = runStateT r2 0 >>= print |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment