Refactor the handling of quasi-quotes
authorSimon Peyton Jones <simonpj@microsoft.com>
Tue, 10 Feb 2015 14:09:12 +0000 (14:09 +0000)
committerSimon Peyton Jones <simonpj@microsoft.com>
Tue, 10 Feb 2015 14:11:39 +0000 (14:11 +0000)
commitf46360ed7139ff25741b381647b0a0b6d1000d84
tree0d44fa5344253999c86a6603055e97d57b809f2e
parent78833ca6305f0875add94351592e141c032cd088
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
55 files changed:
compiler/deSugar/Check.hs
compiler/deSugar/DsArrows.hs
compiler/deSugar/DsExpr.hs
compiler/deSugar/DsMeta.hs
compiler/hsSyn/HsDecls.hs
compiler/hsSyn/HsExpr.hs
compiler/hsSyn/HsExpr.hs-boot
compiler/hsSyn/HsPat.hs
compiler/hsSyn/HsTypes.hs
compiler/hsSyn/HsUtils.hs
compiler/main/Hooks.hs
compiler/parser/Parser.y
compiler/parser/RdrHsSyn.hs
compiler/rename/RnExpr.hs
compiler/rename/RnPat.hs
compiler/rename/RnSource.hs
compiler/rename/RnSplice.hs
compiler/rename/RnTypes.hs
compiler/typecheck/TcEnv.hs
compiler/typecheck/TcExpr.hs
compiler/typecheck/TcHsSyn.hs
compiler/typecheck/TcHsType.hs
compiler/typecheck/TcPat.hs
compiler/typecheck/TcPatSyn.hs
compiler/typecheck/TcRnDriver.hs
compiler/typecheck/TcSplice.hs
compiler/typecheck/TcSplice.hs-boot
testsuite/tests/annotations/should_fail/annfail03.stderr
testsuite/tests/annotations/should_fail/annfail04.stderr
testsuite/tests/annotations/should_fail/annfail06.stderr
testsuite/tests/annotations/should_fail/annfail09.stderr
testsuite/tests/quasiquotation/T3953.stderr
testsuite/tests/quasiquotation/qq001/qq001.stderr
testsuite/tests/quasiquotation/qq002/qq002.stderr
testsuite/tests/quasiquotation/qq003/qq003.stderr
testsuite/tests/quasiquotation/qq004/qq004.stderr
testsuite/tests/th/T10047.hs [new file with mode: 0644]
testsuite/tests/th/T10047.script [new file with mode: 0644]
testsuite/tests/th/T10047.stdout [new file with mode: 0644]
testsuite/tests/th/T2597b.stderr
testsuite/tests/th/T3177a.stderr
testsuite/tests/th/T3395.stderr
testsuite/tests/th/T5358.stderr
testsuite/tests/th/T5795.stderr
testsuite/tests/th/T5971.stderr
testsuite/tests/th/T7276.stderr
testsuite/tests/th/T7276a.stdout
testsuite/tests/th/T7667a.stderr
testsuite/tests/th/T8412.stderr
testsuite/tests/th/TH_1tuple.stderr
testsuite/tests/th/TH_StaticPointers02.stderr
testsuite/tests/th/TH_runIO.stderr
testsuite/tests/th/TH_unresolvedInfix2.stderr
testsuite/tests/th/all.T
utils/haddock