GHC incorrectly warns that a scoped type variable used in a term's body is unused
This bug is reproducible on GHC 8.0.1, 8.0.2, 8.2, and HEAD.
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeInType #-}
{-# OPTIONS_GHC -Wunused-foralls #-}
module Bug where
import Data.Proxy
proxy :: forall k (a :: k). Proxy a
proxy = Proxy
data SomeProxy where
SomeProxy :: forall k (a :: k). Proxy a -> SomeProxy
someProxy :: forall k (a :: k). SomeProxy
someProxy = SomeProxy (proxy @k @a)
$ /opt/ghc/head/bin/ghci Bug.hs
GHCi, version 8.3.20170327: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:17:23: warning: [-Wunused-foralls]
Unused quantified type variable ‘(a :: k)’
In the type ‘forall k (a :: k). SomeProxy’
|
17 | someProxy :: forall k (a :: k). SomeProxy
| ^^^^^^^^
Ok, modules loaded: Bug.
But that a
is used in proxy @k @a
!
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |