Fellow Templaters, Why does test2 () = runQ [| foldr f z xs |] (f,z,xs) = undefined compile fine, but test2 () = runQ [| foldr f z xs |] where (f,z,xs) = undefined fail with this message: ./Language/Haskell/ER/Equation.hs:108:25: Can't splice the polymorphic local variable `f' In the first argument of `foldr', namely `f' In the first argument of `runQ', namely `[| foldr f z xs |]' In the definition of `test2': test2 () = runQ [| foldr f z xs |] where (f, z, xs) = undefined Andy Gill
Check out Section 9.2 in the original TH paper. What you are trying to do is akin to 'genSwap' in that section. In general f depends on the arguments to test2, and so must be converted to code. The paper says this at greater length. Simon | -----Original Message----- | From: template-haskell-bounces@haskell.org [mailto:template-haskell-bounces@haskell.org] On | Behalf Of Andy Gill | Sent: 17 April 2006 05:57 | To: template-haskell@haskell.org | Subject: [Template-haskell] Question about local bindings | | Fellow Templaters, | | Why does | | test2 () = runQ [| foldr f z xs |] | (f,z,xs) = undefined | | compile fine, but | | test2 () = runQ [| foldr f z xs |] | where (f,z,xs) = undefined | | fail with this message: | | ./Language/Haskell/ER/Equation.hs:108:25: | Can't splice the polymorphic local variable `f' | In the first argument of `foldr', namely `f' | In the first argument of `runQ', namely `[| foldr f z xs |]' | In the definition of `test2': | test2 () | = runQ [| foldr f z xs |] | where | (f, z, xs) = undefined | | Andy Gill | | _______________________________________________ | template-haskell mailing list | template-haskell@haskell.org | http://www.haskell.org/mailman/listinfo/template-haskell
participants (2)
-
Andy Gill -
Simon Peyton-Jones