Reification of out-of-scope variables?
Simon Peyton Jones
simonpj at microsoft.com
Fri Apr 15 15:51:06 UTC 2016
| a TExp rather than an Exp. Turns out the example from my first email
| does work if you adapt it to use typed splices:
|
| f :: Int -> Int
| f x = $$(do let {name = mkName x}; info <- reify name; runIO (print
| info) [|| x ||])
Hang on! The design for typed splices, describe here,
https://ghc.haskell.org/trac/ghc/wiki/TemplateHaskell/BlogPostChanges
says "Unlike TH, the only way to construct a value of type TExp is with a quote. You cannot drop into do-notation, nor use explicit construction of the values in the Exp algebraic data type. That restriction limits expressiveness, but it enables the strong typing guarantees."
So why does the above work? $$(e) requires a TExp, and do-notation doesn’t produce a TExp.
| * Should we consider it a bug (and file a ticket) that reification in
| typed splices is able to observe the order of type checking, just like
| reify used to do in untyped splices?
Yes I think so!!!
Simon
More information about the ghc-devs
mailing list