Skip to content

Instantly share code, notes, and snippets.

@bananu7
Created November 11, 2014 10:58
Show Gist options
  • Save bananu7/81c40f2993c670a2a78f to your computer and use it in GitHub Desktop.
Save bananu7/81c40f2993c670a2a78f to your computer and use it in GitHub Desktop.
--hoistState :: Monad m => S.State s a -> S.StateT s m a
--hoistState = S.StateT . (return .) . S.runState
hoistState :: (Monad m, S.MonadState s m) => S.State s a -> m a
hoistState op = do
x <- S.get
let (r, x') = S.runState op x
S.put x'
return r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment