[GHC] #10620: Primitive chars and strings aren't handled by Template Haskell's quasiquoter

GHC ghc-devs at haskell.org
Thu Jul 16 22:07:40 UTC 2015


#10620: Primitive chars and strings aren't handled by Template Haskell's
quasiquoter
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                   Owner:
            Type:  bug               |  RyanGlScott
        Priority:  normal            |                  Status:  new
       Component:  Template Haskell  |               Milestone:
      Resolution:                    |                 Version:  7.10.1
Operating System:  Unknown/Multiple  |                Keywords:
 Type of failure:  GHC rejects       |            Architecture:
  valid program                      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:  #4168, #5218,     |                Blocking:
  #5877,                             |  Differential Revisions:  Phab:D1054
-------------------------------------+-------------------------------------

Comment (by Ben Gamari <ben@…>):

 In [changeset:"2c9de9c9a3df8e855c883139b0cb2fd41801bd67/ghc"]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="2c9de9c9a3df8e855c883139b0cb2fd41801bd67"
 Handle Char#, Addr# in TH quasiquoter (fixes #10620)

 DsMeta does not attempt to handle quasiquoted Char# or Addr# values,
 which causes expressions like `$([| 'a'# |])` or `$([| "abc"# |])` to
 fail
 with an `Exotic literal not (yet) handled by Template Haskell` error.

 To fix this, the API of `template-haskell` had to be changed so that
 `Lit`
 now has an extra constructor `CharPrimL` (a `StringPrimL` constructor
 already
 existed, but it wasn't used). In addition, `DsMeta` has to manipulate
 `CoreExpr`s directly that involve `Word8`s. In order to do this,
 `Word8` had
 to be added as a wired-in type to `TysWiredIn`.

 Actually converting from `HsCharPrim` and `HsStringPrim` to `CharPrimL`
 and
 `StringPrimL`, respectively, is pretty straightforward after that, since
 both `HsCharPrim` and `CharPrimL` use `Char` internally, and
 `HsStringPrim`
 uses a `ByteString` internally, which can easily be converted to
 `[Word8]`,
 which is what `StringPrimL` uses.

 Reviewers: goldfire, austin, simonpj, bgamari

 Reviewed By: simonpj, bgamari

 Subscribers: thomie

 Differential Revision: https://phabricator.haskell.org/D1054

 GHC Trac Issues: #10620
 }}}

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


More information about the ghc-tickets mailing list