Option to value consistent layouting over minimal line count #54
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#54
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?
e.g.
hindent
make it like:and
stylish-haskell
only:But
brittany
just do nothing unless boilerplate take more than 80 chars in string.I don't understand what you mean by
But this seems to be a duplicate of #12. Please complain if I misunderstand.
@lspitzner I just curious about ability to re-format all the lines, even short ones – to get sources formatted same way (not just re-fill long lines). I found similar ability in
hindent
, it even able fix some minor indentation problems. Butbrittany
have much nicer output, so it would by pretty handy to have such functionality (e.g. toindent-region
in text editor, or re-format file on save at least).Ah, using data declaration as an example confused me, as
brittany
does not reformat data decls in any way (yet).Could you provide other example(s) where you dislike the current output of both
brittany
andhindent
, or perhaps where structurally similar stuff is not formatted in the same way bybrittany
? (I admit that such cases probably exist, but I need to know what exactly you mean.)Oh, missed that brittany does not do anything with data declarations yet. Sorry, looks like lazy behaviour is common for source code formatting for all of such tools. However, it still would be very useful to have option to force brittany to be more aggressive with re-indentation and newline insertion on short lines too.
any examples?
currently becomes
But shorter one
becomes ugly
Furthermore, very short
it just leave as is.
Desired behaviour: have option to format all the same way as long lines.
You mean "as short lines", right? The only consistent layout here that would not violate 80 columns would be the
one, right?
For other cases, this might result in a lot of newlines though; I might have to decide this on a case-by-case basis. In general, brittany tries to "pay" with a low amount of newlines for the goal of remaining in 80 columns, and you want to pay some more newlines for the sake of consistency. But it might be hard to balance / hard to decide at which point this price becomes too high.
But for your example at least the price seems reasonable, and it makes sense to support such behaviour behind a flag.
An example where imo the price of consistency would be too high is function application: For long argument,
brittany
usesbut I am pretty sure that I wouldn't want one-liner instances of function application like
foo = foldr a b
to be split into multiple lines even if it is more consistent.Maybe it may be achieved by splitting all together in single one-liner, and than re-formatting.
So I try valid one-liner:
And got:
UPD: just checked:
stylish-haskell
keep this snippet with no error, buthindent
format it in nice way.Yeah, you are right about function application.
What I want to achieve in general: process arbitrary formatted sources with
brittany
to get them in same style.heh, yeah, you found a separate issue :p Feel free to report if it is a usecase you are really interested in.
I don't think that trick would work anyways. But it should be relatively easy to implement this without much trickery - conditionally remove some layouting alternatives (in certain instances,
docAlt
nodes already do that exact thing..)Some other issues have higher priority, but after those I might find time to start implementing this.
I get that, I just suspect you will have a hard time defining "same style" for all kinds of different input, and without things becoming ugly :-)
Thank you for your work and this nice tool =)