Skip to content

Support for records formatting #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Jan 23, 2020

Conversation

lukasz-golebiewski
Copy link
Member

(Optionally) turns this:

module Herp where

data Foo a = Foo { a :: Int, a2 :: String } | Bar { b :: a } 

into

module Herp where

data Foo a = Foo 
  { a :: Int
  , a2 :: String 
  } 
  | Bar
  { b :: a
  }

Copy link
Member

@jaspervdj jaspervdj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for the contribution!

@@ -15,6 +15,10 @@ steps:
# # true.
# add_language_pragma: true

# Format record definitions
- records:
indent: 4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would move the indent setting to the top-level, just like columns, so that other steps may possibly use this value?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea :-) Done
Thanks for the review!

EncodePanda and others added 28 commits January 18, 2020 20:19
Co-authored-by: Łukasz Gołębiewski <[email protected]>
Co-authored-by: Łukasz Gołębiewski <[email protected]>
Co-authored-by: Łukasz Gołębiewski <[email protected]>
Co-authored-by: Łukasz Gołębiewski <[email protected]>
Co-authored-by: Łukasz Gołębiewski <[email protected]>
@EncodePanda
Copy link
Contributor

Hi @jaspervdj, is there anything else you would like us to do in this PR or is it ready to be merged?

EncodePanda and others added 2 commits January 20, 2020 10:45
Co-authored-by: Łukasz Gołębiewski <[email protected]>
Co-authored-by: Łukasz Gołębiewski <[email protected]>
@jaspervdj
Copy link
Member

Hey @EncodePanda, the code looks good to me now; I just need to find some time to manually play with this, try it on a few larger codebases and then it's good to go in -- I promise I'll work on getting that done before the end of the week.

@lukasz-golebiewski
Copy link
Member Author

lukasz-golebiewski commented Jan 21, 2020

Thanks for the review and the approve @jaspervdj !
We've noticed one "slight inconvenience" which is the removal of comments if any existed somewhere inside the data definition. We're going to spend some time on it and try to make sure they are preserved

@jaspervdj
Copy link
Member

Okay, great that you caught that! Another option you could consider is not formatting the data definition at all if there are any comments inside.

@lukasz-golebiewski
Copy link
Member Author

Good idea @jaspervdj! Looks like for now we can do what you suggested only for Haddock style comments, due to how https://hackage.haskell.org/package/haskell-src-exts-1.23.0/docs/Language-Haskell-Exts-Comments.html#v:associateHaddock works

Looks like the problem with comments being removed is more general (see #39) and probably needs to be solved in a separate PR

Co-authored-by: Łukasz Gołębiewski <[email protected]>
@EncodePanda
Copy link
Contributor

We are almost there :) For now we will not format records that have comments in them but we have already a WIP that most likely will fix that (will arrive as a separate PR)

@EncodePanda EncodePanda self-requested a review January 23, 2020 16:38
Copy link
Contributor

@EncodePanda EncodePanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👯‍♂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants