That'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's predicated on already having a valid AST.
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't worked out a good way to do this for Haskell (or, to be fair, any other language). 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. On Mon, Jul 1, 2013 at 10:10 AM, Brandon Allbery <allber...@gmail.com>wrote: > On Mon, Jul 1, 2013 at 9:56 AM, Tikhon Jelvis <tik...@jelv.is> wrote: > >> I'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. >> > > 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'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.) > > -- > brandon s allbery kf8nh sine nomine > associates > allber...@gmail.com > ballb...@sinenomine.net > unix, openafs, kerberos, infrastructure, xmonad > http://sinenomine.net >
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe