`dMatchUpSAKWithDecl` erroneously rejects invisible `forall` without corresponding invisible type variable binder
RyanGlScott opened this issue · comments
Ryan Scott commented
This is a perfectly valid data type:
type D :: forall (a :: Type). Type
data D
Although there is no explicit @a
binder in the declaration for D
, this is perfectly fine, as GHC is capable of inferring it. th-desugar
's dMatchUpSAKWithDecl
function, on the other hand, rejects this. I originally encountered this issue in the context of singletons-th
, but here is a way to trigger the issue using only the th-desugar
API:
{-# LANGUAGE TemplateHaskell #-}
module Bug where
import Data.Kind (Type)
import Language.Haskell.TH hiding (Type)
import Language.Haskell.TH.Desugar
$(do let sak = DForallT (DForallInvis [DKindedTV (mkName "a") SpecifiedSpec (DConT ''Type)]) (DConT ''Type)
bndrs <- dMatchUpSAKWithDecl sak []
runIO $ print $ length bndrs
pure [])
I believe this should work.