Open awalterschulze opened 6 years ago
thanks for reporting.
minimal, currently broken testcase for this is
func = do
let bind = sufficiently loooooooooooooooooooooooooooooooooooooong expression
in bind
which i suppose we want to be layouted exactly like that (?)
Two approaches:
1) Fix the layouter for let..in
to not assume that the indentation of let
and in
is always allowed to be the same
2) Rewrite the syntax-tree to
~~~~.hs
func = do
let bind = sufficiently loooooooooooooooooooooooooooooooooooooong expression
bind
~~~~
Both of which have annoying downsides, afaict.
On a related note, I just noticed that supporting brace style is more complex than I had expected, because
func = do {
let bind = sufficiently loooooooooooooooooooooooooooooooooooooong expression;
bind
}
is not valid haskell. But that is a different topic.
@awalterschulze would you be opposed to 2), or see downsides to it? (my objection is mostly philosophical, in that it would be a first where brittany actually changed the shape of the AST. And the effect on handling of comments during the transformation will probably be tricky.)
I thought the minimally broken test case was with curly braces
func = do {
let bind = sufficiently loooooooooooooooooooooooooooooooooooooong expression
in bind
}
And the break happens, because brittany rewrites all curly brace do notations to space based do notations.
I wouldn't mind either way, as long as brittany does not give an error.
But I did find that when I was using the curly brace style, I never wanted to write the in
in the first place, I needed to, since as you say, it is not possible to write it without the in
So personally I would prefer 2, but it is rewriting it to space based do notation, which allows you to not write in
.
On the other hand, maybe removing in
is more of a thing that hlint
should recommend.
both testcases are valid. both are valid haskell, and are currently transformed into (the same) non-valid haskell by brittany.
On the other hand, maybe removing in is more of a thing that hlint should recommend.
yeah, that matches my reservation.
I'll give this a bit of time, perhaps someone can think of a better alternative. But it should definitely be fixed.
Please excuse my haskell, but I am learning. I just starting using brittany, thank you so much for this tool, I really appreciate it :)
I get an error on the following code:
This code has no problem
And neither does this
which makes me suspect the problem is in reformatting the
do
with curlies, which contains alet
andin
This is low priority, since I can fix the code myself, but I thought I'd report it anyway.