diff options
author | Facundo DomÃnguez <facundo.dominguez@tweag.io> | 2016-07-06 06:48:27 -0300 |
---|---|---|
committer | Facundo DomÃnguez <facundo.dominguez@tweag.io> | 2016-07-06 06:48:27 -0300 |
commit | 567dbd9bcb602accf3184b83050f2982cbb7758b (patch) | |
tree | c7b9930fe4d21db8b38e17edbde9a05dd472de26 /libraries/template-haskell | |
parent | f560a03ccdb246083fe64da3507c5be4c40960fe (diff) | |
download | haskell-567dbd9bcb602accf3184b83050f2982cbb7758b.tar.gz |
Have addModFinalizer expose the local type environment.
Summary:
This annotates the splice point with 'HsSpliced ref e' where 'e' is the
result of the splice. 'ref' is a reference that the typechecker will fill with
the local type environment.
The finalizer then reads the ref and uses the local type environment, which
causes 'reify' to find local variables when run in the finalizer.
Test Plan: ./validate
Reviewers: simonpj, simonmar, bgamari, austin, goldfire
Reviewed By: goldfire
Subscribers: simonmar, thomie, mboes
Differential Revision: https://phabricator.haskell.org/D2286
GHC Trac Issues: #11832
Diffstat (limited to 'libraries/template-haskell')
-rw-r--r-- | libraries/template-haskell/Language/Haskell/TH/Syntax.hs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs index dfcf471f1d..62bdd10aac 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs @@ -458,6 +458,10 @@ addTopDecls ds = Q (qAddTopDecls ds) -- | Add a finalizer that will run in the Q monad after the current module has -- been type checked. This only makes sense when run within a top-level splice. +-- +-- The finalizer is given the local type environment at the splice point. Thus +-- 'reify' is able to find the local definitions when executed inside the +-- finalizer. addModFinalizer :: Q () -> Q () addModFinalizer act = Q (qAddModFinalizer (unQ act)) |