ormolu
ormolu copied to clipboard
Better multiline standalone deriving
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: https://github.com/ghc-proposals/ghc-proposals/pull/446
Sounds neat, being anticipatorily forward-compatible with https://github.com/ghc-proposals/ghc-proposals/pull/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