<div dir="ltr"><div><div>That&#39;s certainly true. As I mentioned, I was actually considering a *pretty-printer* rather than an automatic indentation tool per se. The end results are similar, but the pretty-printer is really only the latter part of the problem: it&#39;s predicated on already having a valid AST.<br>
<br></div>My particular use case involved diffing and merging ASTs directly; this means that I would have to somehow output the result in a human-readable format. Moreover, the actual AST I was outputting could have been the combination of two others, without any prior concrete syntax! I still haven&#39;t worked out a good way to do this for Haskell (or, to be fair, any other language).<br>
<br></div>But yeah, Haskell is pretty intractable as far as language grammars go. I think this is a great compromise--I value language expressiveness over tooling--but it certainly is a compromise.<br></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Mon, Jul 1, 2013 at 10:10 AM, Brandon Allbery <span dir="ltr">&lt;<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="im">On Mon, Jul 1, 2013 at 9:56 AM, Tikhon Jelvis <span dir="ltr">&lt;<a href="mailto:tikhon@jelv.is" target="_blank">tikhon@jelv.is</a>&gt;</span> wrote:<br></div><div class="gmail_extra"><div class="gmail_quote">
<div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div><div><div><div><div>I&#39;ve thought about writing an automatic indenting tool for Haskell (or, more accurately, a pretty-printer) for another project I have, and this is the main thing that threw me off. While automatic indentation might make sense for less expressive languages (Google Go being an extreme example), I think it would be too constraining for Haskell. After all, in reasonable code, chances are that similar constructs end up meaning wildly different things (especially with the advent of pervasive embedded DSLs), so the code itself is a poor indicator of its own structure. <br>

</div></div></div></div></div></div></div></blockquote><div><br></div></div><div>One might look at the history of the indentation modules for Emacs haskell-mode. Short version: they gave up, tab iterates through the possibilities because it&#39;s quite impossible to know which one is correct without a *semantic*, not just syntactic, understanding of the code. (Which, when you think about it, is pretty much par for the Haskell language definition. See also the literally impossible brace insertion rule of Haskell98.)</div>

<div><br></div></div><div class="im">-- <br><div dir="ltr"><div>brandon s allbery kf8nh                               sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>                                  <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div>

<div>unix, openafs, kerberos, infrastructure, xmonad        <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div>
</div></div></div>
</blockquote></div><br></div>