From our lecture notes:
get' state = (state, state)
put' item state = ((), item) -- () is void value
data State s a = State (s -> (a, s))
-- Functions get and put: -- (sic!)
get :: State s s
get = State get'
put :: s -> State s ()
put item = State (put' item)
I am totally lost in these two functions get
and put
.
First, there is no arrow in the type signature of get
:
get :: State s s
What does it mean?
What does s
mean in both get
and put
? Are they state?