[GHC] #16169: Unused variable warning affects compositionality when generating code

#16169: Unused variable warning affects compositionality when generating code -------------------------------------+------------------------------------- Reporter: mpickering | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.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 I'm generating a program using template haskell, I might define a combinator to help me generate lambdas. {{{ type Code a = Q (TExp a) _lam :: (Code a -> Code b) -> Code (a -> b) _lam f = [|| \a -> $$(f [|| a ||]) ||] }}} However, if I now pass a constant function into `_lam`, the generated code contains an unused variable `a` that I can do nothing about and desire not to do anything about. {{{ c5 :: Code (a -> Int) c5 = _lam (const [|| 5 ||]) }}} However, GHC decides that it's wise to warn me about this when I splice it in. {{{
$$c5 F2.hs:6:5: warning: [-Wunused-matches] Defined but not used: ‘a’ | 6 | q = $$c5 | ^^^ }}}
As Ryan will tell you, I'm against emitting warnings from generated code as it breaks the abstraction. The code that is generated is guaranteed to be type and scope correct but any aesthetic warning is irrelevant to the consumer. I see it in precisely the same way as warning if we use a function that contains an unused variable in a library. Once the definition is exported from the library, its definition is opaque. The same principle should be applied to code generated by template haskell. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16169 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16169: Unused variable warning affects compositionality when generating code -------------------------------------+------------------------------------- Reporter: mpickering | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.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 simonpj): It would be easy to suppress all warnings in generated code. We already suppress some. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16169#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16169: Unused variable warning affects compositionality when generating code -------------------------------------+------------------------------------- Reporter: mpickering | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: | TypedTemplateHaskell 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 mpickering): * keywords: => TypedTemplateHaskell -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16169#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16169: Unused variable warning affects compositionality when generating code -------------------------------------+------------------------------------- Reporter: mpickering | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: | TypedTemplateHaskell 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): There's an unfortunate tension here, since other folks have requested //more// warnings from generated code (in #14838). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16169#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC