[GHC] #8263: allow duplicate deriving / standalone deriving

#8263: allow duplicate deriving / standalone deriving ------------------------------------+------------------------------------- Reporter: aavogt | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- I would like to avoid conditional compilation. Currently I need to write: {{{ #if MIN_VERSION_Cabal(1,18,0) -- cabal 1.18 has these instances #else deriving instance Typeable Flag #endif }}} Would it be sane to have the deriving instance do nothing if the imported instance that clashes was also derived? reifyInstances together with a fixed #8100 could allow faking this feature. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8263 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8263: allow duplicate deriving / standalone deriving -------------------------------------+------------------------------------ Reporter: aavogt | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by simonpj): I'd rather not. It's another rule to implement and document in the manual. Why not put `deriving Typeable` on the declaration of `Flag`? Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8263#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8263: allow duplicate deriving / standalone deriving -------------------------------------+------------------------------------ Reporter: aavogt | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by aavogt): Flag comes from cabal: that deriving (Typeable) was added in version 1.18. No code is needed to support that version. Things get messy to support older versions of Cabal which do not export a Typeable instance. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8263#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8263: allow duplicate deriving / standalone deriving -------------------------------------+------------------------------------- Reporter: aavogt | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): I'm also inclined to reject this idea. Given the current richness of `deriving` language, it's possible to derive two instances which are //almost// the same but with subtle differences, e.g., {{{#!hs deriving stock instance Show Bool deriving newtype instance Show Bool }}} I imagine trying to detect duplicate instances would be a large headache. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8263#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8263: allow duplicate deriving / standalone deriving -------------------------------------+------------------------------------- Reporter: aavogt | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: deriving Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * keywords: => deriving -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8263#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8263: allow duplicate deriving / standalone deriving -------------------------------------+------------------------------------- Reporter: aavogt | Owner: (none) Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: wontfix | Keywords: deriving Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by monoidal): * status: new => closed * resolution: => wontfix Comment: In the specific case of Typeable, since GHC 8.2 every data type is an instance of Typeable and we're ignoring "deriving instance Typeable" altogether. In general case, there's the problem of deriving strategies from [comment:3 comment:3]. We could, in principle, allow the declaration "deriving S instance T" if T was derived using the same strategy S elsewhere. However, this only solves the issue if the T was derived; if there's an "instance" declaration, I don't see any nice way to do it. So this feature would be rather limited in power; we don't have examples other than Typeable, and in the meantime #8100 was fixed. I'm closing the ticket; please reopen if you still need this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8263#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC