Hello,

I was wondering if there is a trick for generating a new STArray from a list in such a way that you do not have to hold both the list and array in memory?

http://www.haskell.org/ghc/docs/latest/html/libraries/array-0.3.0.0/Data-Array-MArray.html

As far as I can tell, that is the interface for creating ST Arrays.  For example, newListArray looks almost perfect:

newListArray :: (MArray a e m, Ix i) => (i, i) -> [e] -> m (a i e)

If I know the length of the list, I might expect newListArray to have the memory behavior I want.  In my case, the code calls (length xs) to calculate the length of the list.  As I understand it, that will force the spine of the list into memory.  Can this be avoided?  The only trick that comes into mind is the one used by the C++ vector class where you dynamically resize the array and copy the values to the new array.  That's potentially a lot of copying, right?

Is some other array better suited for this, such as vector or uvector?

Thanks,
Jason