Skip to content

Instantly share code, notes, and snippets.

@dcastro
Last active Sep 29, 2020
Embed
What would you like to do?
Capturing type variables in TemplateHaskell
import Language.Haskell.TH.Lib
import Language.Haskell.TH.Syntax
module Problem where
data PP a where
PP :: forall a. Typeable a => PP a
instance Lift (PP a) where
lift PP = [|PP|]
-- lift PP = unTypeQ ([||PP||] :: Q (TExp (PP a)))
import Language.Haskell.TH.Lib
import Language.Haskell.TH.Syntax
import Problem
module Problem2 where
exp = $(lift (PP @Int))
-- • No instance for (Typeable a0) arising from a use of ‘PP’
-- • In the expression: (PP)
-- In an equation for ‘exp’: exp = (PP)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment