Splices returning splices

J. Garrett Morris Garrett.Morris at ed.ac.uk
Mon Mar 23 16:10:36 UTC 2015

On Mon, Mar 23, 2015 at 3:43 PM, Simon Peyton Jones
<simonpj at microsoft.com> wrote:
> 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).

This may not make any sense, but consider something like this:

  $$(p "a: 1, b: $$(p \"x: 2, y: 3\"), c: 3")

Now, my understanding is that 'p' has a type like 'String -> Q (TExp
a)', where 'a' is instantiated with the expected type of the resulting
expression.  But I don't see how to synthesize the expected type for the
nested (antiquoted) call to 'p' without implementing my own version of
Haskell type inference.  I'd like to be able to return a term that
includes the antiquoted expression, and then rely on the type checker to
properly make the second call to 'p'.


The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

More information about the Glasgow-haskell-users mailing list