If you use the ST monad instead of State, you get actual mutable variables. STArray lets you write typical imperative algorithms that work with mutable arrays, like sieve of Eratosthenes or dynamic programming.<p>Imperative sieve of Eratosthenes:<p><a href="https:&#x2F;&#x2F;gist.github.com&#x2F;rik0&#x2F;1171446#file-erat1-hs" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;rik0&#x2F;1171446#file-erat1-hs</a>