Do not warn on unused newtype constructors when used with FFI
One of the things I love about GHC are the accurate warnings about unused code. This makes refactoring a joy and prevents dead code that is so common in large Java/C++/etc. projects.
It's quite rare that it gets in your way, but one situation where this can happen is with FFI code. Here is an example:
module SomeModule (Context, mkContext) where
import Foreign
newtype Context = Context (Ptr ())
foreign import ccall mkContext :: IO Context
Here GHC warns about the unused newtype consructor.
There are a couple of workarounds that you could use to make this code -Wall sane. But I think they either leak more information about the Context type, or they require an internal "Types" module (which adds maintenance costs and decreases code locality).
I think from a users perspective it would be desirable to omit warnings about unused newtype constructors if the newtype is used in a foreign import declaration.
Trac metadata
Trac field | Value |
---|---|
Version | 7.6.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |