-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
comment DeltaPosition indentation logic #53
Comments
A comment is attached to the preceding AST item. In this case it is The current principle in |
What about the DPs in the following testcase? -- let's start indented, for fun
func =
-- DP == (1, 1) mercury
[
-- DP == (1, 7) venus
foo x
-- DP == (1, 8) earth
| y <- z
-- DP == (1, -2) pluto
-- DP == (1, -3) saturn
, x <- y
-- DP == (1, 2) jupiter
, pred x
-- DP == (1, 1) nepturn
] |
the content of the comments refers to the DP of the comment itself there. |
The important point is what item the comment is attached to. Because the DP is relative to that. |
just to explore alternatives, here are some ideas how DPs for that case might look like: -- status standard previous
-- quo layouting /associated
-- rule only ast item
func =
-- mercury (1, 1) (1,1) (1,1)
[
-- venus (1, 7) (1, 7) (1, 7) or (1, 2) if connected to "foo x"
foo x
-- earth (1, 8) (1, 8) (1, 3)
| y <- z
-- pluto (1, -2) (1, 6) (1, -2)
-- saturn (1, -3) (1, 5) (1, -3)
, x <- y
-- jupiter (1, 2) (1, 10) (1, 1)
, pred x
-- nepturn (1, 1) (1, 1) (1, -10)
]
|
And now that I actually look at the code, I see that comments are put in So It's pretty confusing. |
@lspitzner I want to experiment with this a bit, what is the end result you are trying to achieve for this example in brittany? How should it end up formatted? |
Ah, so many slightly different questions/issues.
|
I will look at this in detail later when I have time. In the meantime, it struck me that adjacent single-line comments should be treated as a single entity in ghc-exactprint. So -- some long explanation
-- for the complex expression below would be formatted as a unit. |
I agree that adjacent single-line comments should retain their alignment, but I am not sure if focusing the implementation on this is the right approach. E.g. if both lines above were independently connected to the following expression |
Sorry, but I will nag once more about the logic behind DeltaPositions/
addEntryDelta
, and under what circumstances the "layouting context" (in relation to which positions are expressed) changes. Consider:From the pure haskell standard perspective, there is only one item in this code affected by the layouting rule: the
func
binding. This means that the "layouting context" for all the above code is column 0, and thus the (entry)deltas should be relative to column 0. Current behaviour is different - some part of the list/monad comprehensions adds an artificial context. This means that I did not fully describe the current behaviour in #48.I'd really appreciate if the documentation could be completed, perhaps by those that actually implemented the behaviour. Most important would be a complete list of the cases where artificial contexts are inserted.
(the above code is not printed correctly via brittany at the moment, as a consequence.)
The text was updated successfully, but these errors were encountered: