Run the
State effect.
Caveats
The
runState interpreter is implemented with
IORefs and
there is no way to do arbitrary atomic transactions. The
state
operation is atomic though and it is implemented with
atomicModifyIORefCAS, which can be faster than
atomicModifyIORef in contention. For any more complicated
cases of atomicity, please build your own effect that uses either
MVars or
TVars based on your need.
Unlike
mtl, in
cleff the state
will not
revert when an error is thrown.
runState will stop taking care of state operations done on
forked threads as soon as the main thread finishes its computation.
Any state operation done
before main thread finishes is still
taken into account.