Closed cblp closed 4 years ago
I'm tempted to classify this as a 'bug' – it hardly seems like this is intentional, and not an accident of the implementation.
Yeah, I haven't found a reasonable way to comment branches
-- two-line
-- comment
then
x
-- another
-- comment
else
y
then -- two-line
-- comment
x
else -- another
-- comment
y
and
then
-- two-line
-- comment
x
else
-- another
-- comment
y
all get reformatted to
then-- two-line
-- comment
x
else-- another
-- comment
y
which seems like it must be a bug.
I just wish I could find some workaround in the interim.
Also, I looked into this recently and it is a tough one. I'd not expect it to be resolved any time soon.
I also ran into this.
I just wish I could find some workaround in the interim.
It's a hack and doesn't play nicely with hlint
, but in some cases you might be able to introduce a do
-block:
foo =
if condition
then do
-- two-line
-- comment
x
else do
-- another
-- comment
y
This doesn't get changed by ormolu.
So I fixed the lack of spacing between else
(and then
) and the following comment. Now you can comment branches like this:
foo =
if undefined
-- then comment
then undefined
-- else comment
else
do
undefined
(I mean, you could before, it was technically correct and idempotent, just a little bit ugly.)
@mrkkrp I don't seem to be able to comment branches like you say (using 0.1.2.0). If I do
foo =
if undefined
-- then comment
then undefined
-- else comment
else
do
undefined
it reformats as
foo =
if undefined
then -- then comment
undefined
else -- else comment
do
undefined
And multi-line comments still have the alignment issue like
foo =
if undefined
then -- then
-- comment
undefined
else -- else
-- comment
do
undefined
But I think it is clear nevertheless which comment belongs to which branch of execution. I do not see a problem with current style. Re alignment—it is a matter of taste, it doesn't look wrong to me.
is reformatted as
Introduced problems: