concept mutable state in category idris

appears as: mutable state, mutable state
Type-Driven Development with Idris

This is an excerpt from Manning's book Type-Driven Development with Idris.

Almost all real-world applications need to manipulate state to some extent. Sometimes, as in the previous examples, state is global and is used throughout an application. Sometimes, state is local to an algorithm; for example, a graph-traversal algorithm will hold the nodes it has visited in local state to avoid visiting nodes more than once. In this chapter, we’ll look at how we can manage mutable state in Idris, both for state that’s local to an algorithm, and for representing overall system state.

12.1. Working with mutable state

Even though Idris is a pure language, it’s often useful to work with state. It’s particularly useful, when writing functions with a complex data structure, such as a tree or a graph, to be able to read and write local state as you’re traversing the structure. In this section, you’ll see how to manage mutable state.