stylish-haskell
stylish-haskell copied to clipboard
newtypes are formatted on two lines with break_single_constructors: false
As newtype
s always have a single constructor, you would think that they
would obey break_single_constructors
. However, with that set to false,
newtype Foo = Foo Int
becomes
newtype Foo
= Foo Int
while data
with a single constructor stay on one line.
data Foo = Foo Int
Okay, having now found the place in the source that explicitly checks this and the test case that claims the current behavior is correct, it seems like @jaspervdj wants this behavior. I still find it unintuitive - if it's not too much configuration bloat could we add a break_newtypes
flag?
I think this accident @imuli . newtype and data have to be consistent. let's fix that.
Hello, any progress on that? Maybe I can help somehow?
Yeah this is accidental. I would welcome a PR that fixes this :-)
IMO this should be the default behavior, but it is somewhat breaking change (people might get big diffs) if we just directly alter the current behavior. If this is acceptable I would go this way as I see no strong reasons to distinguish newtype
and data
in this respect.
Otherwise, @imuli has a fix which should be backwards compatible in cost of introducing a new option.
Which one would you prefer?
I think the primary issue with my fix as it stands is that it doesn't provide any tests?
I also would have no complaints about somone removing the option in favor of break_single_constructors
.