Unsatisfying arithmetic sequences e.g. [0 .. n - 1]
#104
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#104
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?
I'm not really sure what the best practice for the various cases are. These seems pretty reasonable:
I am less certain about more complex expressions. I personally just remove all whitespace within arithmetic sequences, but I don't feel particularly good about it:
But like the title says, this is pretty unsatisfying:
Have you put any thought into the possibilities here?
For what it's worth, I like how Brittany currently formats these. I prefer putting spaces around operators, and I consider
..
to be an operator of sorts.@tfausak I can't really argue. I put spaces around operators, in general. I guess I just got used to seeing no spaces in most of the examples I come across.
Yeah, I'm with @tfausak on this one. I like the way
brittany
is currently formatting.Reminds me of #67 (spaces used in sections). More generally, it is again the decision between "shorter" and "more consistent". There are two reasons for brittany sticking to the "consistency" route currently:
[0..n-1]
would be surprisingly hard to implement, because the layouting of expressions now would be "context sensitive". The simpler cases would still need special-case handling (e.g. if we wanted[literal..literal]
but otherwise[expr .. expr]
).The thought process is
n-1
vsn - 1
- use latter because no context sensitive layouting for exprs[0..n - 1]
vs[0 .. n - 1]
- use latter because former is confusing space-precedence-implication-wise.[0..10]
vs[0 .. 10]
- use latter because more consistent with[0 .. n - 1]
Is that convincing enough? :) I know in both cases there is a lot of code out there that omits the spaces for certain cases, e.g. for sections
(x:)
or(20*)
, and here[1..]
or[a..b]
. And I still do write[1..10]
myself. But I think the current behaviour is the "correct" one.Thanks for taking the time to list your rationale so clearly! My "issue" is resolved.
FWIW our brittany update just changed
[0..5]
to[0 .. 5]
and to throw my opinion out there:I dislike it.
I imagine that doesn't mean a lot, but I felt compelled enough to track down this relevant issue and comment this 😅