We will be using ST s a monad to convert imperative actions into pure actions. ST Monad provides a strictly isolated mutability. ST monad allows access to mutable memory to be strictly inside the ST monad itself. Once we run an ST monad, the mutability goes away, and we get a referentially transparent function. Thus ST monad is very useful in creating an efficient isolated computation where mutability is strictly isolated from outside world, and, by running it, we can embed it as a pure function.
To be able to isolate ST monad, we will use higher ranked data type in this recipe.