summaryrefslogtreecommitdiff
path: root/compiler/prelude/TysWiredIn.hs
diff options
context:
space:
mode:
authorRyanGlScott <ryan.gl.scott@ku.edu>2015-07-17 00:05:14 +0200
committerBen Gamari <ben@smart-cactus.org>2015-07-17 00:08:10 +0200
commit2c9de9c9a3df8e855c883139b0cb2fd41801bd67 (patch)
tree537691587672cacd63f077ec38d36094e7e5fb59 /compiler/prelude/TysWiredIn.hs
parent2c5c29722c78e089eda0baa7ff89154b58f23165 (diff)
downloadhaskell-2c9de9c9a3df8e855c883139b0cb2fd41801bd67.tar.gz
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
Diffstat (limited to 'compiler/prelude/TysWiredIn.hs')
-rw-r--r--compiler/prelude/TysWiredIn.hs20
1 files changed, 19 insertions, 1 deletions
diff --git a/compiler/prelude/TysWiredIn.hs b/compiler/prelude/TysWiredIn.hs
index 5ab8654f06..f7d08ff1c4 100644
--- a/compiler/prelude/TysWiredIn.hs
+++ b/compiler/prelude/TysWiredIn.hs
@@ -42,6 +42,9 @@ module TysWiredIn (
-- * Word
wordTyCon, wordDataCon, wordTyConName, wordTy,
+ -- * Word8
+ word8TyCon, word8DataCon, word8TyConName, word8Ty,
+
-- * List
listTyCon, listTyCon_RDR, listTyConName, listTyConKey,
nilDataCon, nilDataConName, nilDataConKey,
@@ -152,6 +155,7 @@ wiredInTyCons = [ unitTyCon -- Not treated like other tuples, because
, floatTyCon
, intTyCon
, wordTyCon
+ , word8TyCon
, listTyCon
, parrTyCon
, eqTyCon
@@ -198,9 +202,13 @@ listTyConName = mkWiredInTyConName BuiltInSyntax gHC_TYPES (fsLit "[]") li
nilDataConName = mkWiredInDataConName BuiltInSyntax gHC_TYPES (fsLit "[]") nilDataConKey nilDataCon
consDataConName = mkWiredInDataConName BuiltInSyntax gHC_TYPES (fsLit ":") consDataConKey consDataCon
-wordTyConName, wordDataConName, floatTyConName, floatDataConName, doubleTyConName, doubleDataConName :: Name
+wordTyConName, wordDataConName, word8TyConName, word8DataConName :: Name
wordTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Word") wordTyConKey wordTyCon
wordDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "W#") wordDataConKey wordDataCon
+word8TyConName = mkWiredInTyConName UserSyntax gHC_WORD (fsLit "Word8") word8TyConKey word8TyCon
+word8DataConName = mkWiredInDataConName UserSyntax gHC_WORD (fsLit "W8#") word8DataConKey word8DataCon
+
+floatTyConName, floatDataConName, doubleTyConName, doubleDataConName :: Name
floatTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Float") floatTyConKey floatTyCon
floatDataConName = mkWiredInDataConName UserSyntax gHC_TYPES (fsLit "F#") floatDataConKey floatDataCon
doubleTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Double") doubleTyConKey doubleTyCon
@@ -617,6 +625,16 @@ wordTyCon = pcNonRecDataTyCon wordTyConName
wordDataCon :: DataCon
wordDataCon = pcDataCon wordDataConName [] [wordPrimTy] wordTyCon
+word8Ty :: Type
+word8Ty = mkTyConTy word8TyCon
+
+word8TyCon :: TyCon
+word8TyCon = pcNonRecDataTyCon word8TyConName
+ (Just (CType "" Nothing ("HsWord8", fsLit "HsWord8"))) []
+ [word8DataCon]
+word8DataCon :: DataCon
+word8DataCon = pcDataCon word8DataConName [] [wordPrimTy] word8TyCon
+
floatTy :: Type
floatTy = mkTyConTy floatTyCon