brittany doesn't format newlines #250
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#250
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?
It seems as though brittany doesn't do anything to normalize the number of newlines between definitions:
isn't changed at all by brittany.
I think this is intentional. The idea is that if you want to put some new lines between tricky bits of code that aren't necessarily separate declarations, Brittany will allow that. Also it allows for many styles of top-level formatting:
I think that's the current rationale, anyway. It would be nice if this was somehow configurable.
@tfausak Right, though it would be nice if there was some kind of consistency, ie. "at most 1 line between declarations" seems like a decent rule.
I actually rather prefer that brittany doesn't ever mess with my blank lines. Sometimes a lot of space is intentional. I wouldn't mind seeing this as an config option though.
My preference is, no messing with new lines and no configuration.
brittany
and makes it more challenging to maintain and evolve. As it currently stands I'd like to shed some of the existing configuration.I would say that this may be the case on smaller projects with fewer contributors, but once you get loads of people contributing to the same codebase with different ideas of what spacing should look like it quickly becomes a mess. I also think it's worth pointing out that the same argument could be made for the rest of brittany's feature set or for any code formatting at all, eg. the user's idea of formatting
was probably intentional, and therefore we shouldn't touch it.
In my view the whole point of code formatting is uniformity, and that's most people tend to expect from tools in this category.
I think this feature can be implemented in a way that does not intersect with other stuff, either by using a mapping on the annotations (we already pre-process them, so composing one more function is not really complex) or by giving the
BDAnnotationPrior
a new argument. The latter would touch a few places, but still be fairly contained.So in this case I am currently leaning towards "this additional complexity might be worth it".
I agree that this should be disabled by default.
However, there are a couple of annoying design/requirement questions that I would like to address before approaching an implementation:
How to handle comments? I know formatters for other languages that have this feature enabled by default, and that move comments rather strictly down to the next decl. E.g.
Do you want to move the comment? What if there is a newline before the comment, too?
I assume that we want to keep type signature and corresponding equation together, no matter what. Even though both are distinct top-level elements.
There also is the question of how to treat this:
This might not be so bad if we only ever delete too-many newlines, but for standardisation this is very relevant.
This applies to nested decls too, right? Or not? members of type class defs and instances too? between let/where elements? Is this configurable separately?