missing-deriving-strategies could be more helpful
Motivation
Explicit deriving strategies are great for readability.
When missing, it can be very non-obvious which strategy is actually employed. Although this is perhaps documented in various places, there are many special cases to keep in your head.
With the goal of facilitating the transition of all deriving clauses to use explicit strategies within a large codebase,
the existence of -Wmissing-deriving-strategies
is great as a means of highlighting which clauses haven't yet been addressed.
However, the warning/error doesn't inform us as to which strategies would have been implicitly employed.
For example with the following code:
{-# OPTIONS_GHC -Werror=missing-deriving-strategies #-}
{-# LANGUAGE DerivingStrategies #-}
newtype EG = EG Int
deriving (Show, Eq, Ord, Num, Read)
We get the response:
No deriving strategy specified. Did you want stock, newtype, or anyclass?
|
5 | deriving (Show, Eq, Ord, Num, Read)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Proposal
To enhance the -Wmissing-deriving-strategies
message with a hint as to which strategies would have been employed, e.g:
No deriving strategy specified. Did you want stock, newtype, or anyclass?
Suggested fix:
Use explicit deriving strategies:
deriving stock (Show, Read)
deriving newtype (Eq, Ord, Num)
|
5 | deriving (Show, Eq, Ord, Num, Read)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^