concept quiz in category idris

This is an excerpt from Manning's book Type-Driven Development with Idris.
You can use arithInputs as a source of random inputs for quiz and be sure that all the questions will use numbers between 1 and 12. Here’s an example:
*Arith> :exec quiz (arithInputs 12345) 0 Score so far: 0 2 * 1? 2 Correct! Score so far: 1 6 * 2? 18 Wrong, the answer is 12 Score so far: 1 11 * 10? 110 Correct! Score so far: 2You’ve successfully used a source of random Ints as inputs to the quiz, and because randoms (and hence arithInputs) produces an infinite sequence of numbers, you’ll be able to generate new numbers as long as you need to.
There is, however, one remaining problem, which is that quiz itself is not total:
*Arith> :total quiz Main.quiz is possibly not total due to recursive path: Main.quiz, Main.quizThis shouldn’t really surprise you, because there’s nothing in the definition of quiz that allows it to terminate. Instead, like countFrom, randoms, and arithInputs, it’s reading user input and continually producing an infinite sequence of IO actions.
Instead of passing the current score as an argument to the quiz function, maintaining the state by hand, we’ll extend the Command type with commands for giving access to the current score and the difficulty setting.
This is similar to the implementation of quiz at the end of chapter 11, but instead of passing the stream of random numbers and the score as arguments, you treat each of them as state that you read and write as required. This simplifies the definition of quiz, at the cost of making the definition of Command more complex.