Opened 11 months ago

Closed 8 months ago

Last modified 8 months ago

#15798 closed feature request (fixed)

Flag to warn when deriving strategy is not explicitly specified

Reported by: andrewthad Owned by:
Priority: normal Milestone: 8.8.1
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: rename/should_compile/T15798{a,b,c}
Blocked By: Blocking:
Related Tickets: Differential Rev(s): https://gitlab.haskell.org/ghc/ghc/merge_requests/48
Wiki Page:

Description

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 (7)

comment:1 Changed 11 months 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 11 months ago by RyanGlScott

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

comment:3 Changed 11 months 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 11 months ago by RyanGlScott

Keywords: deriving newcomer added

comment:5 Changed 11 months 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.).

comment:6 Changed 8 months ago by RyanGlScott

Differential Rev(s): https://gitlab.haskell.org/ghc/ghc/merge_requests/48
Milestone: 8.8.1
Resolution: fixed
Status: newclosed
Test Case: rename/should_compile/T15798{a,b,c}

Landed in c121e33f9b039acf2ac6939af8bfafe593560039:

Author: chessai <chessai1996@gmail.com>
Date:   Wed Dec 26 12:12:37 2018 -0500

    Add -Wmissing-deriving-strategies
    
    Warn users when -XDerivingStrategies is enabled but not used, at each
    potential use site.
    
    add -Wmissing-deriving-strategies
    
    Reviewers: bgamari, RyanGlScott
    
    Subscribers: andrewthad, rwbarton, carter
    
    GHC Trac Issues: #15798
    
    Differential Revision: https://phabricator.haskell.org/D5451

comment:7 Changed 8 months ago by Ben Gamari <ben@…>

In c121e33f/ghc:

Add -Wmissing-deriving-strategies

Warn users when -XDerivingStrategies is enabled but not used, at each
potential use site.

add -Wmissing-deriving-strategies

Reviewers: bgamari, RyanGlScott

Subscribers: andrewthad, rwbarton, carter

GHC Trac Issues: #15798

Differential Revision: https://phabricator.haskell.org/D5451
Note: See TracTickets for help on using tickets.