concept vending machine in category idris

This is an excerpt from Manning's book Type-Driven Development with Idris.
In this chapter, you’ll see how to make state machines like the one illustrated in figure 13.1 explicit in types. In this way, you can be sure that any function that correctly describes a sequence of actions follows the protocol defined by a state machine. Not only that, you can take a type-driven approach to defining sequences of actions using holes and interactive development. We’ll begin with some fairly abstract examples to illustrate how you can describe state machines in types, modeling the states and operations on a door and a vending machine.
In this section, we’ll model a vending machine using type-driven development, writing types that explicitly describe the input and output states of each operation. As a simplification, the machine accepts only one type of coin (a £1 coin) and dispenses one product (a chocolate bar). Even so, there could be an arbitrarily large number of coins or chocolate bars in the machine, so the number of possible states is not finite.
Table 13.1 describes the basic operations of a vending machine, along with the state of the machine before and after each operation.