<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I believe implementing traverseWithKey_ using a foldWithKey is<br>



quite natural (you want to go over the elements and do something with<br>
them, in this case perform some action on them). I expected it to work<br>
and I am surprised it does not. So for me it is the other way around --<br>
I have a function which I expected to behave nice as a fold and it does<br>
not<br></blockquote><div><br></div><div>Re: expectations.  You don&#39;t get a funny feeling when monadic values are used as first class rather than second class ;-)?  Whether in the accumulator of a fold, or in cases like this:</div>


<div><br></div><div>  do act &lt;- f x</div><div>       act</div><div><br></div><div>My expectation was that the optimizer would have more trouble.  But maybe that&#39;s off base.</div><div><br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><span style="color:rgb(34,34,34)"> Also, heap</span><br></div>
allocation is quite cheap in Haskell, sometimes faster implementations<br>
of containers methods allocate more memory (but we usually do not use<br>
them and prefer less allocation). Wanting to avoid allocation sometimes<br>
causes to avoid higher order functions and advanced functional<br>
techniques, which is also not ideal.<br></blockquote><div><br></div><div>Yes, my situation, which I agree is a minority position, is that I work on and care about parallelism.  The current state of GHC is that it does NOT have a scalable GC, and virtually <b>every</b> parallel program that contains &quot;idiomatic Haskell&quot; levels of allocation fails to scale rather quickly as you increase threads.  I.e. you quickly get to productivities of less than 50%.  (Not necessarily at 32 threads either, often you are up against this wall at 8 or less.)</div>


<div><br></div><div>So for the time being good parallel Haskell programs are low-allocating parallel Haskell programs.</div><div><br></div></div></div></div>