diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2015-02-10 14:09:12 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2015-02-10 14:11:39 +0000 |
commit | f46360ed7139ff25741b381647b0a0b6d1000d84 (patch) | |
tree | 0d44fa5344253999c86a6603055e97d57b809f2e /testsuite/tests/quasiquotation | |
parent | 78833ca6305f0875add94351592e141c032cd088 (diff) | |
download | haskell-f46360ed7139ff25741b381647b0a0b6d1000d84.tar.gz |
Refactor the handling of quasi-quotes
As Trac #10047 points out, a quasi-quotation [n|...blah...|] is supposed
to behave exactly like $(n "...blah..."). But it doesn't! This was outright
wrong: quasiquotes were being run even inside brackets.
Now that TH supports both typed and untyped splices, a quasi-quote is properly
regarded as a particular syntax for an untyped splice. But apart from that
they should be treated the same. So this patch refactors the handling of
quasiquotes to do just that.
The changes touch quite a lot of files, but mostly in a routine way.
The biggest changes by far are in RnSplice, and more minor changes in
TcSplice. These are the places where there was real work to be done.
Everything else is routine knock-on changes.
* No more QuasiQuote forms in declarations, expressions, types, etc.
So we get rid of these data constructors
* HsBinds.QuasiQuoteD
* HsExpr.HsSpliceE
* HsPat.QuasiQuotePat
* HsType.HsQuasiQuoteTy
* We get rid of the HsQuasiQuote type altogether
* Instead, we augment the HsExpr.HsSplice type to have three
consructors, for the three types of splice:
* HsTypedSplice
* HsUntypedSplice
* HsQuasiQuote
There are some related changes in the data types in HsExpr near HsSplice.
Specifically: PendingRnSplice, PendingTcSplice, UntypedSpliceFlavour.
* In Hooks, we combine rnQuasiQuoteHook and rnRnSpliceHook into one.
A smaller, clearer interface.
* We have to update the Haddock submodule, to accommodate the hsSyn changes
Diffstat (limited to 'testsuite/tests/quasiquotation')
5 files changed, 19 insertions, 9 deletions
diff --git a/testsuite/tests/quasiquotation/T3953.stderr b/testsuite/tests/quasiquotation/T3953.stderr index 0a067dd4b2..99c63b1c97 100644 --- a/testsuite/tests/quasiquotation/T3953.stderr +++ b/testsuite/tests/quasiquotation/T3953.stderr @@ -1,2 +1,4 @@ -T3953.hs:5:7: Not in scope: ‘notDefinedHere’ +T3953.hs:5:7: + Not in scope: ‘notDefinedHere’ + In the quasi-quotation: [notDefinedHere| |] diff --git a/testsuite/tests/quasiquotation/qq001/qq001.stderr b/testsuite/tests/quasiquotation/qq001/qq001.stderr index aa748e60cd..350dd418c0 100644 --- a/testsuite/tests/quasiquotation/qq001/qq001.stderr +++ b/testsuite/tests/quasiquotation/qq001/qq001.stderr @@ -1,4 +1,6 @@ qq001.hs:7:16: - GHC stage restriction: parse - is used in a quasiquote, and must be imported, not defined locally + GHC stage restriction: + ‘parse’ is used in a top-level splice, quasi-quote, or annotation, + and must be imported, not defined locally + In the quasi-quotation: [parse||] diff --git a/testsuite/tests/quasiquotation/qq002/qq002.stderr b/testsuite/tests/quasiquotation/qq002/qq002.stderr index b32b5ac6a0..12ab3751dd 100644 --- a/testsuite/tests/quasiquotation/qq002/qq002.stderr +++ b/testsuite/tests/quasiquotation/qq002/qq002.stderr @@ -1,4 +1,6 @@ qq002.hs:8:10: - GHC stage restriction: parse - is used in a quasiquote, and must be imported, not defined locally + GHC stage restriction: + ‘parse’ is used in a top-level splice, quasi-quote, or annotation, + and must be imported, not defined locally + In the quasi-quotation: [parse||] diff --git a/testsuite/tests/quasiquotation/qq003/qq003.stderr b/testsuite/tests/quasiquotation/qq003/qq003.stderr index a1f490fb2c..dd7fa8c872 100644 --- a/testsuite/tests/quasiquotation/qq003/qq003.stderr +++ b/testsuite/tests/quasiquotation/qq003/qq003.stderr @@ -1,4 +1,6 @@ qq003.hs:5:26: - GHC stage restriction: parse - is used in a quasiquote, and must be imported, not defined locally + GHC stage restriction: + ‘parse’ is used in a top-level splice, quasi-quote, or annotation, + and must be imported, not defined locally + In the quasi-quotation: [parse||] diff --git a/testsuite/tests/quasiquotation/qq004/qq004.stderr b/testsuite/tests/quasiquotation/qq004/qq004.stderr index be61788926..7cd33e1e6f 100644 --- a/testsuite/tests/quasiquotation/qq004/qq004.stderr +++ b/testsuite/tests/quasiquotation/qq004/qq004.stderr @@ -1,4 +1,6 @@ qq004.hs:8:21: - GHC stage restriction: parse - is used in a quasiquote, and must be imported, not defined locally + GHC stage restriction: + ‘parse’ is used in a top-level splice, quasi-quote, or annotation, + and must be imported, not defined locally + In the quasi-quotation: [parse||] |