Skip to content

Conversation

Lev135
Copy link
Contributor

@Lev135 Lev135 commented Nov 6, 2022

Fixes #411

I've changed printer's behavior for alignment of deriving closes: now it adds newline and indentation before deriving even if onelineEnum is enabled:

data Foo = A | B | C
  deriving (Eq, Show)

instead of

data Foo = A | B | C deriving (Eq, Show)

This behavior is what is said in docs:

Deriving clauses are always on separate lines

Surely we can add an option to preserve the previous behavior, but I don't think that it's desired for several reasons:

  • it conflicts with docs
  • it leads to an awful output when enum is large, that even not highlight well:
data DefType = DefTEnv | DefTPref | DefTCmd | DefTInl | DefTMode | DefTSort deriving
    ( Eq
    , Ord
    , Show
    )

However, if you think otherwise, I can add an option. Maybe while break_enums option was discussed the reasons of this choice were expained, but I couldn't find anything.

Only two tests were affected by this change:

  • case 20 (establish the break_enums option)

Before:

data Tag = Title | Text deriving (Eq, Show)

After:

data Tag = Title | Text 
  deriving (Eq, Show)

Before:

data Foo = Foo deriving (Z, Y, X, Bar, Abcd)

After:

data Foo = Foo 
  deriving (Z, Y, X, Bar, Abcd)

@Lev135
Copy link
Contributor Author

Lev135 commented Nov 6, 2022

Oh, I've found related issue: #379. I think it should be closed by this pull request

@Lev135 Lev135 changed the title 411 deriving alignment for enums Deriving alignment for enums Nov 6, 2022
@EncodePanda EncodePanda merged commit ba8f471 into haskell:main Nov 6, 2022
@Lev135 Lev135 deleted the 411-deriving-alignment-for-enums branch November 6, 2022 13:33
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.

deriving alignment for enums
2 participants