Suggestion: always indent to the right of the head #146
Labels
No Label
blocked: dependency
blocked: info-needed
bug
duplicate
enhancement
fixed in HEAD
help wanted
hs:arrows
hs:brackets
hs:classes
hs:comments
hs:do-notation
hs:guards
hs:lists
hs:operators
hs:patterns
hs:records
hs:types
invalid
language extension support
layouting
needs confirmation
priority: high
priority: low
question
revisit before next release
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: hexagoxel/brittany#146
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
What I mean is that in situations where the head of an expression is allowed to be to the right of the body, don't do it, and create new lines if necessary.
No:
Yes:
I believe the top example is sometimes called "reverse indent", and I question its use in any situation.
Another way of phrasing this is, "Indent the entire expression first." If, after indenting the whole expression, more indenting is still needed, then so be it:
Does this apply only to function applications? The brittany layouting construct connected to this would be "par-spacing", i.e. the
docSetParSpacing
anddocForceParSpacing
bits of the layouting DSL, whereHsApp
is not the only one includingdocSetParSpacing
. Other users of this are e.g.:(and there are probably some more if you search for either function name.)
Purely on the technical side, one can remove such invocations, but it is not possible to restrict specific interactions of two specific
docSetParSpacing
/docForceParSpacing
uses.phrased differently: the node to the right of "=" is currently allowed to have "par-spacing" and several layouters currently set the required "bit", and
HsApp
is only one of them.Ah, interesting! You're right, I was just thinking of function application. (
do
is a funny case; I could almost get behind Chris Done's preference of not using par-spacing for it, too.)Let me see if turning off par-spacing for HsApp does what I want.
The complete list of cases:
Of these, the ones I would want to change are HsApp and one case of RecordUpd. Here are my commentary on all the uses:
cec0f19bcf
EDIT: New amended commit that removes superfluous comments.
Removing some uses doesn't break any tests. I can't figure out what syntax is needed to exercise them. The use on line 183 is the only one I'd like to actually compare. Can you write a test that shows different behavior depending on whether or not line 183 gets commented out?
Oh, wait, that's one that looks easy to test. It has a comment already! I think the others are obvious enough.
No, I lied, I can't figure out how to test it.
I got busy, and I don't know if I'll make any headway on this any time soon.
Sorry, I never followed up on this either. It still is on my to-do list to find those testcases you asked for, when I find time.
@chreekat
Finally found some time (sorry). And after trying to find the difference line 183 makes, I have to admit that it probably is indeed superfluous, and this comes down to one detail that I had not mentioned yet:
The par-spacing flag is set implicitly for BriDoc values that are a sequence, where
I.e. the "par-spacing" flag automatically moves upwards from the last element of a sequence to the sequence as a whole.
And in the stuff below line 183, we mandate the exact preconditions for this flag-forwarding, so we only permit layouts that already receive a forwarded par-spacing flag. I have added a comment about this in the code for now.
If it was your intention to disable this flag instance, this certainly does not make things easier. Disabling the forwarding is probably not what we want (without testing, i think there are several other cases that would be affected..), so the "simplest" solution would perhaps be a new node that forces the flag off again..