#7408: Do not warn on unused newtype constructors when used with FFI
-----------------------------+----------------------------------------------
Reporter:  SimonHengel       |          Owner:                  
    Type:  feature request   |         Status:  new             
Priority:  normal            |      Component:  Compiler        
 Version:  7.6.1             |       Keywords:                  
      Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
 Failure:  None/Unknown      |      Blockedby:                  
Blocking:                    |        Related:                  
-----------------------------+----------------------------------------------
 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.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7408>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to