<div dir="ltr"><div class="gmail_extra">Yes, hindent is exponential in its pretty printing and that's exactly the program I'm trying to speed up ;) To be specific, hindent has `sandbox` which runs a printer and then lets me make decisions on what the resulting state might be. I'm curious if there are other approaches.<div><br></div><div>- ocharles</div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 11, 2014 at 12:01 PM, Alan & Kim Zimmerman <span dir="ltr"><<a href="mailto:alan.zimm@gmail.com" target="_blank">alan.zimm@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><p dir="ltr">Have you looked at hindent?</p><div class="gmail_quote"><div><div class="h5">On 11 Oct 2014 11:52 AM, "Oliver Charles" <<a href="mailto:ollie@ocharles.org.uk" target="_blank">ollie@ocharles.org.uk</a>> wrote:<br type="attribution"></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hi all,<div><br></div><div>It seems that all of the pretty printing libraries on Hackage at the moment have an emphasis on being compact, but not necessarily consistent. By consistent, I mean that similar blocks of code are indented in the same fashion, even when not strictly necessary.</div><div><br></div><div>Take for example, the start of "Pretty Printing with Lazy Dequeues". Here, the example is:</div><div><br></div><div>if True</div><div>   then if True then True else True</div><div>   else</div><div>      if False</div><div>         then False</div><div>         else False</div><div><br></div><div>I call this inconsistent, because the two sides of the top-level if have been formatted under different rules. A consistent formatting of this would be:</div><div><br></div><div><div>if True</div><div>   then </div><div>      if True </div><div>         then True </div><div>         else True</div><div>   else</div><div>      if False</div><div>         then False</div><div>         else False</div></div><div><br></div><div>The above can obviously be reached if you *always* format `if` in this style, but that's not what I'm after. If it's possible to format both sides on one-line, then that should be preferred. So an equally desirable output (that meets my "consistency" requirement) is:</div><div><br></div><div><div>if True</div><div>   then if True then True else True</div><div>   else if True then True else True</div><div><br></div></div><div>It doesn't seem that there is a library on Hackage that lets one express such a pretty printer. It seems that a pretty printer of this nature would need to have some sort of backtracking ability - I can imagine trying to print both sides of the if statement on one-line, and if this fails, try printing *both* on multiple lines.</div><div><br></div><div>Curious to hear what people have to say on this matter,</div><div>- ocharles</div></div><br></div></div>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br><br></blockquote></div></blockquote></div></div></div></div>