Skip to content

Instantly share code, notes, and snippets.

@dcastro
Last active September 29, 2020 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcastro/20175fdbf2e43a77c9504d98e9fa3c36 to your computer and use it in GitHub Desktop.
Save dcastro/20175fdbf2e43a77c9504d98e9fa3c36 to your computer and use it in GitHub Desktop.
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