20 ms·
And Haskell: import Control.Monad.Reader type Action = ReaderT String IO () foo :: Action foo = do bar local (const "new state") b
by jrockway 16y ago
And Haskell:
import Control.Monad.Reader
type Action = ReaderT String IO ()
foo :: Action
foo = do
bar
local (const "new state") bar
bar
bar :: Action
bar = liftIO . putStrLn =<< ask
> runReaderT foo "foo"
foo
new state
foo