[Haskell-cafe] STM, newArray, and a stack overflow?
ketil at malde.org
Wed Mar 23 21:07:28 CET 2011
Bas van Dijk <v.dijk.bas at gmail.com> writes:
> sequence ms = foldr k (return ) ms
> k m m' = do
> x <- m
> xs <- m'
> return (x:xs)
Isn't this really a strictness problem with the STM monad? If I
understand correctly, this forces xs before x can be examined. Something
to be fed to listArray should be able to be consumed lazily, shouldn't
> Note that I used a difference list to keep the list in the right
> order. Alternatively you can use a normal list (x:r) and reverse it
> when done. I'm not sure what's more efficient.
Hm, they will all need to allocate everything on the heap, no?
Shouldn't it be possible to create an array in a loop with only constant
> Does this suggest we need the left folded sequencel?
It's interesting to see that newArray is using listArray under the
covers, I really want to initialize the array from a list - but
neither a listArray function nor the TArray constructor seem to be
Thanks for helping out!
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe