Skip to content

Instantly share code, notes, and snippets.

@mstksg
Last active January 20, 2017 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mstksg/dac60de20e44879110a5b1c076985178 to your computer and use it in GitHub Desktop.
Save mstksg/dac60de20e44879110a5b1c076985178 to your computer and use it in GitHub Desktop.
foo :: StateT s m Int
bar :: Int -> StateT s m Bool
-- using State appropriately
baz :: StateT s m Bool
baz = do
x <- foo
bar x
-- ignoring the State abstraction
baz :: StateT s m Bool
baz = StateT $ \s -> do
(x, s') <- runStateT foo s
runStateT (baz x) s'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment