Skip to content

Limit duplicate export warnings for datatypes

containers sometimes exports data constructors/patterns conditionally (depending on GHC version and whether TESTING is defined). Presently, to avoid a duplicate export warning, it's necessary to write a separate export line for each combination of exported constructors, which is horrible:

module Foo (
#ifdef TESTING
#ifdef USE_PATTERN_SYNONYMS
  Foo (Foo, Pat1, Pat2)
#else
  Foo (Foo)
#endif
#elif USE_PATTERN_SYNONYMS
  Foo (Pat1, Pat2)
#else
  Foo
#endif

or to break up the lines with CPP, which is so horrible I can't even bring myself to write it.

I'd much rather be able to write

module Foo (
   Foo
#ifdef TESTING
  ,Foo(Foo)
#endif
#ifdef USE_PATTERN_SYNONYMS
  ,Foo(Pat1, Pat2)
#endif
  )

The trouble here is that GHC warns about duplicate export of the type Foo. I think there's a pretty simple partial solution: only warn about a type export that is *completely* redundant, adding neither type constructor nor pattern. And offer a way to turn off the redundant export warning entirely for types and classes without turning it off for bindings.

Trac metadata
Trac field Value
Version 7.10.3
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information