Hi All, I am trying to use template haskell to splice top level declarations. However, GHC complains "<interactive>:1: Variable not in scope: `splice'" May I know what is the problem here? Did I use the wrong syntax? -W-M- @ @ | \_/
On Sun, 13 Mar 2005 23:31:28 +0800 (GMT-8), WANG Meng
Hi All,
I am trying to use template haskell to splice top level declarations. However, GHC complains "<interactive>:1: Variable not in scope: `splice'"
From http://www.haskell.org/ghc/docs/6.4/html/users_guide/template-haskell.html: 'Note that the syntax for a declaration splice uses "$" not "splice" as in the paper. Also the type of the enclosed expression must be Q [Dec], not [Q Dec] as in the paper.'
-- Friendly, Lemmih
From http://www.haskell.org/ghc/docs/6.4/html/users_guide/template-haskell.html: 'Note that the syntax for a declaration splice uses "$" not "splice" as in the paper. Also the type of the enclosed expression must be Q [Dec], not [Q Dec] as in the paper.'
Thank you for your reply. I also tried to use "$". But GHC gives *Main> $(myparseDec "x=1") <interactive>:1: Couldn't match `Exp' against `Dec' Expected type: ExpQ Inferred type: Q Dec In the application `myparseDec "x=1"' In the definition of `it': it = $[splice](myparseDec "x=1") It seems "$" only takes in an "Q Exp". -W-M- @ @ | \_/ On Sun, 13 Mar 2005, Lemmih wrote:
On Sun, 13 Mar 2005 23:31:28 +0800 (GMT-8), WANG Meng
wrote: Hi All,
I am trying to use template haskell to splice top level declarations. However, GHC complains "<interactive>:1: Variable not in scope: `splice'"
-- Friendly, Lemmih
On Mon, 14 Mar 2005 01:38:25 +0800 (GMT-8), WANG Meng
From http://www.haskell.org/ghc/docs/6.4/html/users_guide/template-haskell.html: 'Note that the syntax for a declaration splice uses "$" not "splice" as in the paper. Also the type of the enclosed expression must be Q [Dec], not [Q Dec] as in the paper.'
Thank you for your reply. I also tried to use "$". But GHC gives
*Main> $(myparseDec "x=1")
<interactive>:1: Couldn't match `Exp' against `Dec' Expected type: ExpQ Inferred type: Q Dec In the application `myparseDec "x=1"' In the definition of `it': it = $[splice](myparseDec "x=1")
It seems "$" only takes in an "Q Exp".
You can't splice top level declarations from the interactive prompt. Save the code in a file and all will be well. (Notice that the TH code can't be in the module where the splicing takes place, and that your function should have the type 'Q [Dec]' instead of 'Q Dec'.) -- Friendly, Lemmih
participants (2)
-
Lemmih -
WANG Meng