<font face="'Helvetica Neue', 'Helvetica Neue', Helvetica, Arial, sans-serif"><span style=" font-size:14px; font-family:'Helvetica Neue', 'Helvetica Neue', Helvetica, Arial, sans-serif;">Something like this would be useful for making an hsfmt or something similar.<div><br></div><div>Stylish-haskell does some of this, but it is rather opinionated.<br><br>–<div>Kyle Marek-Spartz</div><div> </div><div> </div><div> </div><div id="replyBeginsHere"><div> </div><div> </div><div> </div>On Oct 11, 2014, 4:52:18 AM, Oliver Charles <ollie@ocharles.org.uk> wrote:<hr>
<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>Haskell-Cafe mailing list
<br>Haskell-Cafe@haskell.org
<br>http://www.haskell.org/mailman/listinfo/haskell-cafe
<br> <br><br></div></div></span></font>