Exercise 23.8.2
in the haskell book asks me to construct a state like the following:
put' :: s -> State s ()
put' s = undefined
-- should act like:
-- Prelude> runState (put "blah") "woot"
-- ((),"blah")
The only implementation I have gotten to typecheck is
import Control.Monad.Trans.State -- Not sure this is the right import
put' :: s -> State s ()
put' s = state $ \s -> ((), s)
But this returns the state in the argument of runState
, not put'
:
λ> runState (put' "blah") "woot"
((),"woot")
What haskell acrobatics do I need to fix this? Do not see how I can access the "blah"
.