Arrows for managing an explicit state
State arrows work similar to state monads. A state value is threaded through the application of arrows.
The interface for accessing and changing the state component.
Multi parameter classes and functional dependencies are required.
read the complete state, ignore arrow input
definition: getState = accessState (\ s x -> s)
overwrite the old state
definition: setState = changeState (\ s x -> x)
change state (and ignore input) and return new state
convenience function, usefull for generating e.g. unique identifiers:
example with SLA state list arrows
newId :: SLA Int b String newId = nextState (+1) >>> arr (('#':) . show) runSLA 0 (newId <+> newId <+> newId) undefined = ["#1", "#2", "#3"]