Typed Template Haskell suppresses -Wunused-top-binds warnings
In this program:
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -Wunused-top-binds #-}
module Bug (a) where
a :: Int
a = $([| 42 |])
-- a = $$([|| 42 ||])
z :: Int
z = 42
GHC correctly informs me that z
is defined but not used:
$ /opt/ghc/8.10.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o, Bug.dyn_o )
Bug.hs:10:1: warning: [-Wunused-top-binds]
Defined but not used: ‘z’
|
10 | z = 42
| ^
If I comment out the definition of a
and replace it with a = $$([|| 42 ||])
, however, then GHC doesn't report any warnings at all!
$ /opt/ghc/8.10.3/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o, Bug.dyn_o )
I'm unclear why the use of typed Template Haskell would change things here, as I would expect -Wunused-top-binds
warnings in both scenarios.