Skip to content

Defined but not used warning on records used by servant-client

When generating an HTTP client through the servant-client lib (https://hackage.haskell.org/package/servant-client), if the various API record accessors go unused elsewhere, -Wunused-top-binds will generate warnings of the style "Defined but not used: {accessor}.

I believe this is somewhat misleading, as the accessors are indeed "used" in the process of generating the client.

Some sample code that will generate a warning for the release accessor:

type API = "release" :> Capture "mbid" Mbid :> Get '[JSON] Listing

type Mbid = UUID

data Listing = Listing
  { release :: Text
  } deriving (Show, Generic)

instance FromJSON Listing

coverArtArchiveAPI :: Proxy API
coverArtArchiveAPI  = Proxy

getListing :: Mbid -> ClientM Listing
getListing = client coverArtArchiveAPI
Trac metadata
Trac field Value
Version 8.0.1
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