Inconsistent validity checking for unnamed vs. named wildcards
GHC HEAD rejects the following program:
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE NamedWildCards #-}
{-# LANGUAGE PolyKinds #-}
{-# OPTIONS_GHC -Wno-partial-type-signatures #-}
module Bug where
import Data.Proxy
class C k (a :: k)
f :: (C _ a) => Proxy a
f = Proxy
GHCi, version 8.9.20190220: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:12:9: error:
Wildcard ‘_’ not allowed in a constraint
except as the last top-level constraint of a type signature
e.g f :: (Eq a, _) => blah
in the type signature for ‘f’
|
12 | f :: (C _ a) => Proxy a
| ^
But it accepts it if you change _
to _k
, a named wildcard!
f :: (C _k a) => Proxy a
f = Proxy
This feels strangely inconsistent to me, as I would have expected GHC's treatment of these two programs to be the same.