haskell / stylish-haskell

Haskell code prettifier
Other
983 stars 150 forks source link

Keeping the deriving clause of a record on the same line as the closing curly brace #308

Open tchoutri opened 4 years ago

tchoutri commented 4 years ago

Hi, I just upgraded to the latest stylish-haskell binary, but I would like to keep the previous behaviour where, in the case of a sole deriving clause, said clause is kept on the same line as the closing curly brace of the record.

Right now, the current settings produce this kind of formatting

data Test                  
  = Test { top    :: Int   
         , bottom :: String
         }                 
  deriving (Show)          

Which I personally find quite awkward.

Would you be open to a pull request implementing a configuration option for this behaviour?

tchoutri commented 4 years ago

ping @jaspervdj

jaspervdj commented 4 years ago

@tchoutri Yep, I don't have much time to do this myself but definitely happy to look at a PR.

However, I'm in the progress of finalizing porting stylish-haskell to ghc-lib-parser -- see #307.

Would it be possible to branch of ghc-lib-parser/merge and PR into that rather than master?

tchoutri commented 4 years ago

Oh I can even wait for the PR to be completed, no worries about that! Good luck with it, though!

jaspervdj commented 3 years ago

@tchoutri The PR is merged now, so feel free to work on this anytime :-)

tchoutri commented 3 years ago

@jaspervdj Alright, that's going to be fun then :P

tchoutri commented 3 years ago

@jaspervdj I've opened a PR to track my work, but I have to admit some the code in Step.Data is a bit nebulous when discovering the codebase. Especially this code:

          sep (newline >> spaces cDerivingIndent) $ defn & dd_derivs & \(L pos ds) -> ds <&> \d -> do
              putAllSpanComments (newline >> spaces cDerivingIndent) pos
              putDeriving cfg d

Would you be available for a quick chat someday? :)

jaspervdj commented 3 years ago

@tchoutri Ah! Yes, I think that code isn't super idiomatic so if you want to rewrite it or rip it out, feel free. If it would be any help to you, we can also do so over screenshare, my agenda is pretty open tomorrow afternoon, just drop me an email.

jaspervdj commented 3 years ago

@tchoutri How is this progressing? Let me know if you can use some more help on it. :-)

tchoutri commented 3 years ago

@jaspervdj hi! other duties came in the way, but I'll resume my work starting next week. I'll drop you an email if needs be. :)