[GHC] #15839: DerivingStrategies defaulting warning has no associated enable/suppress flag

#15839: DerivingStrategies defaulting warning has no associated enable/suppress flag -------------------------------------+------------------------------------- Reporter: tejon | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Poor/confusing Unknown/Multiple | error message Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- When `DerivingStrategies`, `DeriveAnyClass` and `GeneralizedNewtypeDeriving` are enabled together, an instance that could be derived with either `newtype` or `anyclass` throws a warning when no strategy is specified. It appears to be impossible to suppress this warning. Even `-w` doesn't work! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15839 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15839: DerivingStrategies defaulting warning has no associated enable/suppress flag -------------------------------------+------------------------------------- Reporter: tejon | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: | Keywords: deriving, | newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * keywords: => deriving, newcomer Comment: To be more precise, this has nothing to do with `DerivingStrategies`, but rather the interaction between `DeriveAnyClass` and `GeneralizedNewtypeDeriving`. The following code is a minimal example of the issue: {{{#!hs {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} module Bug where class C a newtype T a = MkT a deriving C }}} {{{ $ /opt/ghc/8.6.1/bin/ghci Bug.hs GHCi, version 8.6.1: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Bug ( Bug.hs, interpreted ) Bug.hs:6:30: warning: • Both DeriveAnyClass and GeneralizedNewtypeDeriving are enabled Defaulting to the DeriveAnyClass strategy for instantiating C • In the newtype declaration for ‘T’ | 6 | newtype T a = MkT a deriving C | ^ Ok, one module loaded. }}} Indeed, there is no flag associated with this warning, so there is currently no way to suppress this. I don't think this would be too difficult to fix, luckily. All you'd need to do is: 1. Think of a name for a flag to control this warning. 2. Toggle whether this warning gets emitted or not behind said flag. Any volunteers? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15839#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15839: DerivingStrategies defaulting warning has no associated enable/suppress flag -------------------------------------+------------------------------------- Reporter: tejon | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: | Keywords: deriving, | newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by tejon): Ah, good catch -- I guess I never tried without `DerivingStrategies`. I'll update the bug description, and include your minimum example. For flag name I nominate `-Wderiving-defaults`, after the pattern of `-Wtype-defaults`. It sounds like this would be an easy way to get my toes wet in the GHC codebase. If there's no argument with my flag suggestion, I'll try to implement it myself. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15839#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15839: DerivingStrategies defaulting warning has no associated enable/suppress flag -------------------------------------+------------------------------------- Reporter: tejon | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: | Keywords: deriving, | newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by tejon: Old description:
When `DerivingStrategies`, `DeriveAnyClass` and `GeneralizedNewtypeDeriving` are enabled together, an instance that could be derived with either `newtype` or `anyclass` throws a warning when no strategy is specified. It appears to be impossible to suppress this warning. Even `-w` doesn't work!
New description: When `DeriveAnyClass` and `GeneralizedNewtypeDeriving` are enabled together, an instance that could be derived with either one defaults to `DeriveAnyClass` and throws a warning to that effect. There is currently no flag to suppress that warning (it appears even with `-w`). In the presence of `DerivingStrategies`, it seems desirable to be able to suppress this. Proposed flag to control it: `-Wderiving-defaults`, after the pattern of `-Wtype-defaults`. This flag should be part of the default warning set, as without `DerivingStrategies` it remains a bad idea to have both newtype and anyclass active. Minimal example (thanks RyanGIScott): {{{ {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} module Bug where class C a newtype T a = MkT a deriving C }}} {{{ $ /opt/ghc/8.6.1/bin/ghci Bug.hs GHCi, version 8.6.1: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Bug ( Bug.hs, interpreted ) Bug.hs:6:30: warning: • Both DeriveAnyClass and GeneralizedNewtypeDeriving are enabled Defaulting to the DeriveAnyClass strategy for instantiating C • In the newtype declaration for ‘T’ | 6 | newtype T a = MkT a deriving C | ^ Ok, one module loaded. }}} -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15839#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15839: DerivingStrategies defaulting warning has no associated enable/suppress flag -------------------------------------+------------------------------------- Reporter: tejon | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: | Keywords: deriving, | newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: #16179 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * related: => #16179 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15839#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC