Skip to content
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

Better multiline standalone deriving #943

Open
brandonchinn178 opened this issue Dec 8, 2022 · 1 comment
Open

Better multiline standalone deriving #943

brandonchinn178 opened this issue Dec 8, 2022 · 1 comment
Labels
style Nitpicking and things related to purely visual aspect for formatting.

Comments

@brandonchinn178
Copy link
Collaborator

Without DerivingStrategies, it's reasonable to think that "deriving instance" together defines a standalone deriving statement, but with DerivingStrategies, it seems more intuitive for deriving + the strategy to be one unit, and instance + types being another. This makes the styling look just like a normal instance block.

Current

newtype Foo = Foo Int

deriving instance
  Show Foo

deriving via
  (Hex Int)
  instance
    Show Foo

deriving newtype instance
  Show Foo

Desired

newtype Foo = Foo Int

deriving 
  instance Show Foo

deriving newtype
  instance Show Foo

deriving via (Hex Int)
  instance Show Foo

-- if the user explicitly puts it on the next line, perhaps even
-- deriving
--   via (Hex Int)
--   instance Show Foo

Environment

  • OS name + version:
  • Version of the code:

Additional context
Related: ghc-proposals/ghc-proposals#446

@amesgen amesgen added the style Nitpicking and things related to purely visual aspect for formatting. label Dec 8, 2022
@amesgen
Copy link
Member

amesgen commented Dec 8, 2022

Sounds neat, being anticipatorily forward-compatible with ghc-proposals/ghc-proposals#446 could be sufficient reason to change formatting here (multi-line deriving clauses are also usually pretty self-contained), such that this will be a fixed point:

deriving newtype
  instance Show Foo
  instance Read Foo

deriving via -- or also change the newline insertion here
  (Hex Int)  -- as suggested in your examples
  instance
    Show Foo
    Read Foo

@mrkkrp mrkkrp added this to the 0.7.4.0 milestone Jan 19, 2024
@mrkkrp mrkkrp removed this from the 0.7.4.0 milestone Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
style Nitpicking and things related to purely visual aspect for formatting.
Projects
None yet
Development

No branches or pull requests

3 participants