In-scope check for type variables can be confusing in presence of invisible kind arguments
From #19764 (closed), thanks to @yaitskov:
{-# LANGUAGE DeriveLift #-}
{-# LANGUAGE StandaloneDeriving #-}
module Main where
import Language.Haskell.TH.Syntax (Lift (..))
newtype Ref = Ref { r :: ()} deriving (Lift)
deriving instance Lift ()
main :: IO ()
main = pure ()
This prints
/Users/rae/temp/Bug.hs:8:41: error:
• Overlapping instances for Lift ()
arising from the first field of ‘Ref’ (type ‘()’)
Matching instances:
two instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
• When deriving the instance for (Lift Ref)
|
8 | newtype Ref = Ref { r :: ()} deriving (Lift)
|
The "instances involving out-of-scope types" are both Lift ()
. Note that Lift
is in scope. So GHC must be confused about ()
, which is a shame.