Skip to content

Instantly share code, notes, and snippets.

@YoEight
Last active August 29, 2015 14:07
Show Gist options
  • Save YoEight/bfaf9acbfe570820f6f2 to your computer and use it in GitHub Desktop.
Save YoEight/bfaf9acbfe570820f6f2 to your computer and use it in GitHub Desktop.
A different State encoding (solution here https://gist.github.com/YoEight/0541aa293effbfff8d02)
{-# LANGUAGE RankNTypes #-}
newtype State s a = State { runState :: forall r. s -> (a -> s -> r) -> r }
stateReturn :: a -> State s a
stateReturn = undefined
stateMap :: (a -> b) -> State s a -> State s b
stateMap = undefined
stateBind :: (a -> State s b) -> State s a -> State s b
stateBind = undefined
stateGet :: State s s
stateGet = undefined
statePut :: s -> State s ()
statePut = undefined
stateModify :: (s -> s) -> State s ()
stateModify = undefined
execState :: s -> State s a -> s
execState = undefined
evalState :: s -> State s a -> a
evalState = undefined
@YoEight
Copy link
Author

YoEight commented Oct 2, 2014

Oops... It's fixed now. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment