Open amesgen opened 3 years ago
But what a top-level tuple or a list mean?
TH.Lift
instances. :grin:test =
(1
,2)
which one might try to format via ormolu --start-line 2
(which will fail right now, even though the file can be formatted as a whole).
Right, so it's mostly important in the context of region formatting.
The solution here would be to identify these situations and shift the closing parenthesis or brace like we already do in certain situations.
Edit: it might actually introduce a discrepancy between the output obtained by formatting the whole file vs formatting regions of a file separately. I believe that shifting the closing parenthesis might be not necessary in this case (i.e. when the function is formatted as a whole):
test =
( 1,
2
)
Right, so it's mostly important in the context of region formatting.
Not exactly.
But what a top-level tuple or a list mean?
This is just a pattern. Consider:
a, b :: Int
(a, b) = (1, 2)
Another example of a multiline pattern might be
a, b :: Int
Foo
a
b = mkFoo 42
Apparently for multiline patterns the subsequent lines must always be indented more than the first column of the first line of the pattern.
@buggymcbugfix The cases you mention are already correctly handled by Ormolu, or am I missing something in your comment?
I didn't check if they are correctly handled, but I assume they would be. I was merely answering @mrkkrp's question.
Yeah, but the cases you mention are not top-level tuples/lists, but different constructs. But the asymmetry between tuple expressions and tuple patterns is indeed surprising:
a = (a
,a)
is valid (even with less indentation in the second line), but
(a
,a) = a
is not.
Describe the bug The snippet
is formatted (with
--unsafe
) towhich can not be parsed. The closing parens/brackets can't be in the first column.
Environment Ormolu 0.2.0.0