RE: Question about local bindings

"Simon Peyton-Jones" <[email protected]> Tue, 18 Apr 2006 13:01:45 +0100
Newsgroups gmane.comp.lang.haskell.template
Message-ID <036EAC76E7F5EC4996A3B3C3657D411605237238@EUR-MSG-21.europe.corp.microsoft.com>
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: [email protected]
[mailto:[email protected]] On
| Behalf Of Andy Gill
| Sent: 17 April 2006 05:57
| To: [email protected]
| 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
| [email protected]
| http://www.haskell.org/mailman/listinfo/template-haskell