[Haskell-cafe] Getting results of of runSTUArray

Henning Thielemann lemming at henning-thielemann.de
Wed Oct 20 12:53:18 EDT 2010


On Wed, 20 Oct 2010, Henry Laxen wrote:

> I am trying to do something that I think should be very simple, but I
> just can't seem to figure out how.  The idea is that I want to use
> runSTUArray to build up an array, but I want to look at the array
> after each iteration and possiblely accumulate some elements.

The result of runSTUArray is an immutable array, it cannot be altered 
anymore, only read and transformed to a new copy. Everything that modifies 
the array must happen inside runSTUArray.

If you want other things than an array out of the ST monad then use runST.


More information about the Haskell-Cafe mailing list