stylish-haskell icon indicating copy to clipboard operation
stylish-haskell copied to clipboard

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

Open tchoutri opened this issue 5 years ago • 9 comments

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 avatar Sep 19 '20 15:09 tchoutri

ping @jaspervdj

tchoutri avatar Sep 23 '20 20:09 tchoutri

@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?

jaspervdj avatar Sep 24 '20 17:09 jaspervdj

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

tchoutri avatar Sep 24 '20 17:09 tchoutri

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

jaspervdj avatar Oct 04 '20 13:10 jaspervdj

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

tchoutri avatar Oct 04 '20 18:10 tchoutri

@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? :)

tchoutri avatar Oct 04 '20 19:10 tchoutri

@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 avatar Oct 04 '20 22:10 jaspervdj

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

jaspervdj avatar Oct 11 '20 12:10 jaspervdj

@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. :)

tchoutri avatar Oct 11 '20 16:10 tchoutri