[commit: ghc] master: Handle Char#, Addr# in TH quasiquoter (fixes #10620) (2c9de9c)

git at git.haskell.org git at git.haskell.org
Thu Jul 16 22:08:07 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/2c9de9c9a3df8e855c883139b0cb2fd41801bd67/ghc

>---------------------------------------------------------------

commit 2c9de9c9a3df8e855c883139b0cb2fd41801bd67
Author: RyanGlScott <ryan.gl.scott at ku.edu>
Date:   Fri Jul 17 00:05:14 2015 +0200

    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


>---------------------------------------------------------------

2c9de9c9a3df8e855c883139b0cb2fd41801bd67
 compiler/deSugar/DsMeta.hs                         | 13 ++++++++
 compiler/hsSyn/Convert.hs                          |  1 +
 compiler/prelude/PrelNames.hs                      |  9 ++---
 compiler/prelude/THNames.hs                        | 15 ++++++---
 compiler/prelude/TysWiredIn.hs                     | 20 +++++++++++-
 docs/users_guide/glasgow_exts.xml                  | 38 +++++++++++++++++++++-
 libraries/template-haskell/Language/Haskell/TH.hs  |  2 +-
 .../template-haskell/Language/Haskell/TH/Lib.hs    |  2 ++
 .../template-haskell/Language/Haskell/TH/Ppr.hs    |  1 +
 .../template-haskell/Language/Haskell/TH/Syntax.hs |  1 +
 testsuite/tests/th/T10620.hs                       |  9 +++++
 testsuite/tests/th/T10620.stdout                   |  2 ++
 testsuite/tests/th/all.T                           |  1 +
 13 files changed, 103 insertions(+), 11 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 2c9de9c9a3df8e855c883139b0cb2fd41801bd67


More information about the ghc-commits mailing list