Skip to content

Instantly share code, notes, and snippets.

@n4to4
Created December 4, 2017 09:33
Show Gist options
  • Save n4to4/dda8073573ff3637ac86fd6c3b817957 to your computer and use it in GitHub Desktop.
Save n4to4/dda8073573ff3637ac86fd6c3b817957 to your computer and use it in GitHub Desktop.
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