On Nov 17, 2007 3:04 PM, apfelmus <<a href="mailto:apfelmus@quantentunnel.de">apfelmus@quantentunnel.de</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br></div>Unfortunately, I don't have Paulson's book (or any other ML book :) at<br>home. I'm too lazy to figure out the specification from the source code,</blockquote><div><br>I guess the code is too opaque, as my colleague claimed.
<br></div><div><br>The layout the algorithm generates condensed indented blocks. Within a block, it inserts a newline when the distance to the next break point plus the current position is greater than the space remaining on the current line. Thus if S-Expression lists are rendered as blocks with indent two, and every element in a list is separated by a break point of length one, with the proper margin, you would see:
<br><br>(defthingy name-of-thingy<br> (one thing) (two thing)<br> (a-big-thing-made-bigger)<br> (three thing) (four thing))<br><br>As an exercise, the book asks you to implement group indent, where if any break point in a group inserts a newline, they all do. So with that layout, one would get:
<br><br>(defthingy<br> name-of-thingy<br> (one thing)<br> (two thing)<br> (a-big-thing-made-bigger)<br> (there thing)<br> (four thing))<br><br>The C version I wrote supports this layout, but I didn't bother with that extension for the Haskell version.
<br><br>On the strictness annotations, my reasons for them are the usual ones, primarily to prevent memory leaks due to dragging, but a performance boost is always welcome. At some point, I plan to profile the code with and without the annotations, and find out where they are needed.
<br><br>John<br> </div></div><br>