Last active
September 29, 2020 08:20
-
-
Save dcastro/20175fdbf2e43a77c9504d98e9fa3c36 to your computer and use it in GitHub Desktop.
Capturing type variables in TemplateHaskell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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