Opened 7 weeks ago

Last modified 7 weeks ago

#15798 new feature request

Flag to warn when deriving strategy is not explicitly specified

Reported by: andrewthad Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.6.1
Keywords: deriving, newcomer Cc: RyanGlScott
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


In my code, I aim to always specify deriving strategies. I would like to add a flag -fwarn-unspecified-deriving that would cause a warning to be emitted when someone wrote this:

newtype Foo = Foo Int
  deriving (Show)

The user would be required to instead write:

newtype Foo = Foo Int
  deriving newtype (Show)

Or they could use stock if that was the behavior they wanted. This flag would be off by default.

Change History (5)

comment:1 Changed 7 weeks ago by andrewthad

Cc: RyanGlScott added

Ryan, if you to see if you had any thoughts on the name of the flag, I am welcome to suggestions.

comment:2 Changed 7 weeks ago by RyanGlScott

One other suggestion I've heard is -Wimplicit-deriving-strategies (mirroring the name of the ImplicitPrelude extension).

comment:3 Changed 7 weeks ago by andrewthad

That does sound better. I'll go with that. And I'm glad to know that someone else has thought about such a flag before.

comment:4 Changed 7 weeks ago by RyanGlScott

Keywords: deriving newcomer added

comment:5 Changed 7 weeks ago by monoidal

I would suggest -Wmissing-deriving-strategies, as there are several -Wmissing-* flags (missing-local-signatures, missing-import-lists, missing-home-modules etc.).

Note: See TracTickets for help on using tickets.