Splices returning splices

Simon Peyton Jones simonpj at microsoft.com
Mon Mar 23 15:43:42 UTC 2015


Currently it just isn't supported.  Suppose you say

f x = [| ....$(g y).... |]

...$(f 3)....

Does $(f 3) mean "run (f 3) returning some code with embedded splices, and then run those", or does it mean (as now) "call (f 3), and to do so run (g y) first, to generate some code that is spliced into the code returned by f"?

A quasiquoter is really a splice. That is [foo| blah |] is the same as $(foo "blah").  So it might be easier to discuss your question in the context of ordinary splices and quotes.  You want foo to return code with a splice, thus:

foo input_string = [| ...$(other_fun args).... |]

But foo is in the Q monad anyway, so why not just run (other_fun args) right there in the quasiquoter?

Or perhaps make a tiny example to show what you mean (but not using quasiquotation).

Simon 

|  -----Original Message-----
|  From: Glasgow-haskell-users [mailto:glasgow-haskell-users-
|  bounces at haskell.org] On Behalf Of J. Garrett Morris
|  Sent: 23 March 2015 12:47
|  To: GHC users
|  Subject: Splices returning splices
|  
|  Hello,
|  
|  I'm attempting to write a quasiquoter with relatively full antiquotation
|  support.  In doing so, I've arrived at I think an odd problem: the
|  expression grammar in Language.Haskell.TH.Syntax doesn't seem to include
|  splices.  This seems to mean that my antiquotations can't themselves
|  include splices, which is quite limiting.  Am I misinterpreting?  The
|  type system in "Template metaprogramming for Haskell" seems to imply no
|  such restriction on the occurrences of splices.
|  
|  (As an additional complication: what I really need to do is return typed
|  splices; my "quasiquoter" relies on its expected type to determine its
|  behavior.  However, this seems like an uninteresting extension of the
|  above problem.)
|  
|  Thanks,
|  
|   /g
|  
|  --
|  The University of Edinburgh is a charitable body, registered in Scotland,
|  with registration number SC005336.
|  
|  _______________________________________________
|  Glasgow-haskell-users mailing list
|  Glasgow-haskell-users at haskell.org
|  http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users


More information about the Glasgow-haskell-users mailing list