I'm trying to write a Lift instance that lifts not only the constructor, but also its type variables.
For example, take Proxy a. I need a Lift instance such that, when lift (Proxy @Int) is spliced, GHC will correctly infer than the generated expression is a Proxy Int.
-- GHC should infer that x :: Proxy Int
x = $(TH.lift (Proxy @Int))
I tried this:
instance Lift (Proxy a) where
lift _ = [|Proxy @a|]
x = $(TH.lift (Proxy @Int))
It seems TH captured a and not Int as expected.
I'm not sure what else to try
/.../TH/Test.hs:15:7: error:
• The exact Name ‘a’ is not in scope
Probable cause: you used a unique Template Haskell name (NameU),
perhaps via newName, but did not bind it
If that's it, then -ddump-splices might be useful