DerivingStrategies should not require individual strategy extensions to be enabled
Motivation
Currently, DerivingStrategies
requires individual extensions to be enabled in order to use each strategy. For example, if DerivingStrategies
is enabled, but DeriveAnyClass
is not, then deriving anyclass (Foo)
will always fail.
This might not seem like much of a problem, but the issue is that enabling DeriveAnyClass
changes the rules about which strategy is used by default—specifically, it causes the anyclass
strategy to be prioritized over the newtype
strategy, making GeneralizedNewtypeDeriving
useless without explicitly specifying deriving newtype
.
Generally speaking, I use newtype
deriving far more often than I want to use anyclass
deriving, so I’d like to keep DeriveAnyClass
disabled to avoid it being chosen implicitly. However, I’d still like to be able to opt into the anyclass
strategy explicitly when I want to use it using the syntax introduced by DerivingStrategies
.
Proposal
A solution to this is simple enough: allow any strategy to be used explicitly when DerivingStrategies
is enabled, and change the individual extensions to only alter how strategies are implicitly selected. I don’t think that really has any meaningful drawbacks. DerivingVia
could remain its own extension, since it is never implicitly selected as a deriving strategy anyway, but I don’t really care about that one way or the other.
A potential alternative would be to add weaker versions of GeneralizedNewtypeDeriving
and DeriveAnyClass
, which could be named GeneralizedNewtypeDerivingStrategy
and DeriveAnyClassStrategy
. Those extensions would enable individual strategies for use with DerivingStrategies
, but they would never be chosen implicitly. Personally, I don’t see much advantage in doing so, but it’s a more conservative approach that still solves the issue.