
Hal Daume III
writes: [snip my functions that use the ST monad to do (//)]
You shouldn't try to write these functions. You should do all array modifications within the ST monad, rather than looking for a pure solution.
All right, but why? It seems an obvious trick, take some pieces that benefit from imperative processing, and wrap them in ST, leaving the rest of the program as it were.
Can you (or anybody else) explain the memory behaviour I see (using hundreds of megabytes, but only tens of K visible in the profiling output)?
That's because currently large objects aren't included in the profile. There's no really good reason for this, except that threads (including their stacks) count as large objects, and seeing them in the profile might be confusing. On the other hand, it might also be enlightening if you have a program that uses a lot of stack space. I'll look into fixing this. Cheers, Simon

"Simon Marlow"
That's because currently large objects aren't included in the profile.
Okay, I didn't know that.
I'll look into fixing this.
Great! But just knowing about it also helps a lot. Since you're on the line, could you confirm or deny that the (//) operator is something equivalent to (roughly): a // ps = runST (thaw a >>= \u -> update ps >> unsafeFreeze u) I.e. that the list of updates are treated as an atomic operation? Because doing it that way explicitly sure didn't seem to help. OTOH, doing lots of small (//) seems to be faster than doing a few large ones (containing the same updates). Go figure. BTW: does anybody know an accepted fastest way of doing in-place permutations on an array? -kzm -- If I haven't seen further, it is by standing in the footprints of giants
participants (2)
-
Ketil Z Malde
-
Simon Marlow