A State
effect can be seen as the combination of both a
Reader
and a Writer
with these operations:
get
get the current state
put
set a new state
Let’s see an example showing that we can also use tags to track
different states at the same time:`> initial:
(10,hello), final: (5,10)`
In the example above we have used an eval
method to get
the A
in Eff[R, A]
but it is also possible to
get both the value and the state with run
or only the state
with exec
.
Instead of tagging state effects it is also possible to transform a State effect acting on a “small” state into a State effect acting on a “bigger” state:``
> (there are 3 values
the sum is 6,(3,6))