Reification of out-of-scope variables?

Simon Peyton Jones simonpj at microsoft.com
Fri Apr 15 15:57:08 UTC 2016


|  > * If part of the solution here is to use typed splices, how do we get
|  > quasiquotation to be syntactic sugar for a *typed* splice? Do we want
|  > to be introducing a typed quasiquotation syntax, just like Geoff did
|  > for much of the rest of Template Haskell?
|  
|  Maybe. Quasiquotation sugar is very light: [blah|...|] is the same as
|  $(selector blah "...") where `selector` is the right record selector
|  depending on the splice context. Is it worth trying to expand
|  quasiquotation syntax to work with typed TH? I'm unconvinced it's worth
|  the bother. Also, note that doing [blah||...||] is not backward-
|  compatible, because that looks like an untyped quasiquote that begins
|  and ends with a vertical bar. 

The merit of a typed splice is that if you see
	$$(f [|| x ||])
and (f [|| x ||]) typechecks, then you know that the splice result will typecheck. You never have to look at the expansion of the splice.

Nothing like that can be said about quasiquotes
	[flob| ...arbitrary string... |]

We can't say "if ...arbitrary string.. typechecks then the quasiquote will typecheck.

To put it another way, it's equivalent to

	$(getExprParser flob "...arby string....")

and that typechecks trivially, but its expansion of course might not.

So there is literally no point in thinking about typed-splices for quasiquotes.

Simon


More information about the ghc-devs mailing list