<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">From: Heinrich Apfelmus &lt;<a href="mailto:apfelmus@quantentunnel.de">apfelmus@quantentunnel.de</a>&gt;<br>

<br>
Jason Dagit wrote:<br>
&gt; Heinrich Apfelmus wrote:<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m curious, can you give an example where you want to be explicit about<br>
&gt;&gt; chunking? I have a hard time imagining an example where chunking is<br>
&gt;&gt; beneficial compared to getting each character in sequence. Chunking<br>
&gt;&gt; seems to be common in C for reasons of performance, but how does that<br>
&gt;&gt; apply to Haskell?<br>
&gt;<br>
&gt; [...]<br>
&gt; I think it basically comes down to this: We replace lazy io with explicit<br>
&gt; chunking because lazy io is unsafe, but explicit chunking can be safe.<br>
<br>
Ah, I mean to compare Iteratees with chunking to Iteratees with single<br>
character access, not to lazy IO.<br>
<br>
In C, this would be a comparison between  read  and  getchar . If I<br>
remember correctly, the former is faster for copying a file simply<br>
because copying one character at a time with  getchar  is too granular<br>
(you have to make an expensive system call every time). Of course, this<br>
reasoning only applies to C and not necessarily to Haskell.<br>
<br>
Do you have an example where you want chunking instead of single<br>
character access?<br></blockquote><div><br></div><div>I am unable to think of any examples where you want chunking for any reason other than efficiency.  Yesterday I spent some time on an element-wise iteratee implementation, and unfortunately it&#39;s significantly slower than any of the chunked implementations.  I&#39;m certain there&#39;s room for optimization, but I don&#39;t know if it&#39;s possible to make up the whole difference.  I&#39;d need to make some examination of the core to figure out where it could be improved.</div>
<div><br></div><div>It&#39;s also possible that certain other implementations, such as your ProgramT version or the simplified implementation John Millikin recently posted to this list, would be more amenable to compiler magic for this purpose.</div>
<div><br></div><div>John</div></div>