Squash but don't remove blank lines
Purty seems to clobber out any blank lines intentionally placed within the code. I think blank lines serve an important function to sort of separate out the "paragraphs" of our code. Multiple blank lines should be squashed into a single blank line, but single blank lines should be left as is. I don't know a lot about code formatting tools, but this seems to be consistent at least with standard, which I found to be a pretty sensible code formatter.
I also think this rule could help to sort out a lot of other rules within purty, such as #134 (closed) and #107 (closed), e.g: Instead of worrying about putting newlines between case statements, we can let the user decide that by either putting or not putting them.
Here's an example (for completeness)
Unformatted:
-- Heres a test function
test :: CaseType -> Effect String
test myType = do
-- Do Some Stuff here
void $ pure $ show "Hello friends!"
void $ launchMissles $ (10+12+13)
void $ launchMissles $ (1 + 9 / 2)
-- Figure out our result
case myType of
-- Here's the first case
Type1 x -> do
let x' = x + 10
pure $ show x'
-- Heres the second case
Type2 xs -> do
pure $ joinByComma xs
Formatted:
-- Heres a test function
test :: CaseType -> Effect String
test myType = do
-- Do Some Stuff here
void $ pure $ show "Hello friends!"
void $ launchMissles $ (10 + 12 + 13)
void $ launchMissles $ (1 + 9 / 2)
-- Figure out our result
case myType of
-- Here's the first case
Type1 x -> do
let
x' = x + 10
pure $ show x'
-- Heres the second case
Type2 xs -> do
pure $ joinByComma xs
But I would have expected this to come out more like:
-- Heres a test function
test :: CaseType -> Effect String
test myType = do
-- Do Some Stuff here
void $ pure $ show "Hello friends!"
void $ launchMissles $ (10 + 12 + 13)
void $ launchMissles $ (1 + 9 / 2)
-- Figure out our result
case myType of
-- Here's the first case
Type1 x -> do
let
x' = x + 10
pure $ show x'
-- Heres the second case
Type2 xs -> do
pure $ joinByComma xs
I dont necessarily think that this rule is 100% correct, but I feel like something in this direction would be good. I'm open to discussion about it!