[GHC] #13608: Expose the type of quasiquotes

GHC ghc-devs at haskell.org
Tue Jun 6 12:10:21 UTC 2017


#13608: Expose the type of quasiquotes
-------------------------------------+-------------------------------------
        Reporter:                    |                Owner:
  facundo.dominguez                  |  facundo.dominguez
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:
       Component:  Template Haskell  |              Version:  8.0.1
      Resolution:                    |             Keywords:  QuasiQuotes
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  12778             |  Differential Rev(s):  Phab:D3610
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 >  Looks like typed splices and quasiquotes will pose some gotchas.

 Ah, yes, I understand what's happening here, and (once again) it's
 awkward.

 GHC has to compile ''and run'' the term inside the splice, here `$$(q)`.
 But since `q :: forall a. C a => Q (TExp a)`, looking at `$$(q)` in
 isolation we just see that `q` has type `Q (TExp alpha)` with constraint
 `C alpha`, but we don't know what `alpha` is.  It'll ultimately be fixed
 by the `asTypeOf (0::Int)` part, but not yet.

 If you change it to `$$(q) :: Int` then it does work because the
 information about the `Int` type is pushed inwards from the type
 signature.  That is horribly delicate, and I had not realised it before.

 The robust way to do it would be `$$(q :: Q (TExp Int))`, putting all the
 type info inside the splice.

 This doesn't happen for untyped splices because they don't expect to get
 any type info from the context.

 I think I should probably ''stop'' pushing type info from the context into
 a typed splice, so that it would fail reliably.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13608#comment:14>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list