Skip to content

Unavoidable "unused bindings" warnings in boot files

The -fwarn-unused-binds flag produces warnings for bindings that cannot, in fact, be deleted from hs-boot files. It would be nice not to see these warnings. Definitions in .hs-boot files must match the definitions in .hs files, but .hs-boot files don't necessarily use or export the same identifiers that the .hs file does.

Running ghc -c A.hs-boot -fwarn-unused-binds produces warnings for this hs-boot file, regardless of whether the identifiers are exported in the hs file.

{- A.hs-boot -}
{-# OPTIONS_GHC -XTypeFamilies #-} -- to demonstrate associated type warnings
module A(Foo, HasFoo) where

newtype Foo = Foo {unFoo :: Int}
class HasFoo a where
  data Foo' a
  getFoo :: a -> Foo

For identifiers defined on the RHS of an equal sign or 'where'---namely, data constructors, field names, class methods, and associated types---I suggest silencing unused binding warnings in the boot file. The rationale is that you should be allowed to copy an entire definition into the boot file, and regard a binding as unused only if it appears unused in the .hs file.

See also #3283.

Trac metadata
Trac field Value
Version 6.10.4
Type Bug
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