Skip to content

-Wunused-type-patterns warns on used type variables

Summary

import Data.Kind (Type)

type family UnApply (fx :: Type) :: Type -> Type where
  forall (f :: Type -> Type) (x :: Type).
    UnApply (f x) = f -- warns about unused `x`
[1 of 1] Compiling Main             ( Test.hs, interpreted )

Test.hs:4:31: warning: [-Wunused-type-patterns]
    Defined but not used on the right hand side: type variable ‘x’
  |
4 |   forall (f :: Type -> Type) (x :: Type).
  |                               ^

If a type variable is needed on the LHS, yet not used on the RHS, GHC will warn with -Wunused-type-patterns, even if removing that variable or replacing it with _ will give an error.

Steps to reproduce

Compile above example with -Wunused-type-patterns.

Expected behavior

It should not give a warning.

Environment

  • GHC version used: 9.2.4
Edited by Las Safin
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information