
Just to be clear, I *think* layout rules don't apply here at all, actually.
If I understand correctly, "layout" has to do with turning spacing into
braces and semicolons. A new line is a semicolon. A brace group is inserted
around things that are aligned where a brace group actually makes sense.
e.g.
let x = y
y = z
in ...
gets turned into roughly
let { x = y
; y = z
} in ...
if-then-else however is just an expression, like a ternary operator, so it
doesn't need any semicolons or braces. So layout is unrelated, except for
the issue of `do` blocks inserting semicolons into `if-then-else` groups
(and that's what DoAndIfThenElse fixes).
-- Andrew
PS. I am very glad someone is working on ghc-exactprint. It's a really
important step in developing better Haskell tooling, imho. Doing that sort
of thing right now with haskell-src-exts right now is a real pain (see half
of the closed issues on hindent... about how it doesn't preserve formatting
in many places.)
On Tue, Mar 10, 2015 at 9:25 AM, Alan & Kim Zimmerman
Ok, adding a do does make a difference. More complexity.
Thanks Alan
On Tue, Mar 10, 2015 at 6:06 PM, Brandon Allbery
wrote: On Tue, Mar 10, 2015 at 12:01 PM, Alan & Kim Zimmerman < alan.zimm@gmail.com> wrote:
I am working on ghc-exactprint, and need to flag points where layout must be preserved, and considering the `if` statement.
My understanding of the layout rules for if then else is that the `then` has to start more to the right than the `if`.
I believe you are looking for DoAndIfThenElse.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe