ST Monad
The ST monad allows in-place updates, but is escapable, meaning some values in the internal context can be returned. The type signature is
1 | ST s a |
The type signature means that they returns a value of type a and is executed in the context s.
The most important method is runST, basically, it executes a ST monad and gets the returned value.
1 | runST :: forall a. (forall s. ST s a) -> a |
In-place Operations
References/variables that can be used within the ST monad are provided in Data.STRef and arrays are in Data.Array.ST
Data.STRef
Data.STRef1 | -- a value of `STRef s a` is a mutable variable |