TP wrote: > pr :: Name -> ExpQ > pr n = [| putStrLn $ (nameBase n) ++ " = " ++ show $(varE n) |]
The example is indeed problematic. Let's consider a simpler one: > foo :: Int -> ExpQ > foo n = [|n + 1|] The function f, when applied to an Int (some bit pattern in a machine register), produces _code_. It helps to think of the code as a text string with the source code. That text string cannot include the binary value that is n. That binary value has to be converted to the numeric text string, and inserted in the code. That conversion is called `lifting' (or quoting). The function foo is accepted because Int is a liftable type, the instance of Lift. And Name isn't. BTW, the value from the heap of the running program inserted into the generated code is called `cross-stage persistent'. The constraint Lift is implicitly generated by TH when it comes across a cross-stage persistent identifier. You can read more about it at http://okmij.org/ftp/ML/MetaOCaml.html#CSP Incidentally, MetaOCaml would've accepted your example, for now. There are good reasons to make the behavior match that of Haskell. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe