[GHC] #11309: Warn on shady data constructor export

#11309: Warn on shady data constructor export -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- If a module defines a datatype and exports some, but not all, of the constructors, then modules importing the type will find it difficult to perform sensible and total case analyses. This is most likely to be a problem when a module that names exported constructors adds a new constructor. Could we get a warning for this, please? Note: this applies also to data family instances. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11309 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11309: Warn on shady data constructor export -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.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 goldfire): Sounds quite sensible to me. +1. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11309#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11309: Warn on shady data constructor export -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.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 mpickering): I don't understand the situation where this warning would be useful. If you want to export all the constructors then can you not use a wildcard? If this warning is implemented and turned on by -Wall then is there any way to export some constructors warning free? It seems to me the only situation where you explicitly list the constructors is when you don't want to export them all. Maybe there is a better example to do with data families which I am missing. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11309#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11309: Warn on shady data constructor export -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.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 dfeuer): Replying to [comment:2 mpickering]:
I don't understand the situation where this warning would be useful. If you want to export all the constructors then can you not use a wildcard? If this warning is implemented and turned on by -Wall then is there any way to export some constructors warning free? It seems to me the only situation where you explicitly list the constructors is when you don't want to export them all.
Maybe there is a better example to do with data families which I am missing.
You might want to avoid a wildcard so people reading the module header will see all the exported names. I would argue that it's highly unusual to want to export only some constructors. Generally, you either want to keep the type abstract or to expose it fully. Can you think of a solid reason for exporting only some constructors? As for turning warnings off, every existing warning flag has `-fno-warn-...`. This would be no different. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11309#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC