Skip to content

template haskell: incorrect Warning: defined but not used

example code:

{-# LANGUAGE TemplateHaskell #-}

module THWarnBug where

import Language.Haskell.TH

mhlt :: Q Type
mhlt = do
  let u = [t| String |]
  [t| $u |]

compiling gives:

$ ghc -c -Wall THWarnBug.hs 

THWarnBug.hs:9:6: Warning: Defined but not used: `u'

but obviously u is used.

Trac metadata
Trac field Value
Version 6.12.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