
Bas van Dijk
sequence ms = foldr k (return []) ms where 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 it?
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 memory overhead?
Does this suggest we need the left folded sequencel?
Or unsafeInterleaveSTM? 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 available. Thanks for helping out! -k -- If I haven't seen further, it is by standing in the footprints of giants