@@ -1,37 +1,8 @@
1−From d78e5ce3fb865ec1c1659817b0bba1a1bccc692c Mon Sep 17 00:00:00 2001
2−From: Matthew Bauer <mjbauer95@gmail.com>
3−Date: Sat, 1 Jun 2019 07:04:31 -0400
4−Subject: [PATCH] Make qNewUnique return a Uniq instead of an Int
7−https://gitlab.haskell.org/ghc/ghc/commit/4ba73e00c4887b58d85131601a15d00608acaa60,
8−`Uniq` is an `Integer` instead of `Int`. The `qNewUnique` function,
9−however, currently returns an `Int` by using `fromIntegral` to
10−convert the `Integer` to an `Int`. This is potentially dangerous,
11−however, as this could truncate large `Integer`s down into smaller
12−`Int`s, which has the potential to return non-unique `Int`s.
14−Instead of doing this, let's simply make `qNewUnique` return a `Uniq`
15−without any modification. The only place where `singletons` uses
16−`qNewUnique` is for the purpose of turning the `Uniq` directly into
17−a `String` anyway, so this is a perfectly fine thing to do.
19−This is originally Matthew Bauer's patch from #398, which was an
20−abandoned attempt at fixing a separate GHCJS bug. Since this patch is
21−useful on its own merits, I (@RyanGlScott) have modified the commit
22−message to reflect its new purpose.
24−Co-authored-by: Matthew Bauer <mjbauer95@gmail.com>
25−Co-authored-by: Ryan Scott <ryan.gl.scott@gmail.com>
27− src/Data/Singletons/Util.hs | 6 +++---
28− 1 file changed, 3 insertions(+), 3 deletions(-)
30diff --git a/src/Data/Singletons/Util.hs b/src/Data/Singletons/Util.hs
1diff --git a/src/Data/Singletons/Util.hs b/src/Data/Singletons/Util.hs
31−index 8ffdcf96..f28d6329 100644
2+index 0f8f788..d5a06ef 100644
32--- a/src/Data/Singletons/Util.hs
3--- a/src/Data/Singletons/Util.hs
33+++ b/src/Data/Singletons/Util.hs
4+++ b/src/Data/Singletons/Util.hs
34−@@ -91,11 +91,11 @@ qReportError :: Quasi q => String -> q ()
5+@@ -92,7 +92,7 @@ qReportError :: Quasi q => String -> q ()
35 qReportError = qReport True
6 qReportError = qReport True
37 -- | Generate a new Unique
8 -- | Generate a new Unique
@@ -40,12 +11,7 @@ index 8ffdcf96..f28d6329 100644
40 qNewUnique = do
11 qNewUnique = do
41 Name _ flav <- qNewName "x"
12 Name _ flav <- qNewName "x"
42 case flav of
13 case flav of
43−- NameU n -> return $ fromIntegral n
45− _ -> error "Internal error: `qNewName` didn't return a NameU"
47− checkForRep :: Quasi q => [Name] -> q ()
48−@@ -202,7 +202,7 @@ suffixName ident symb n =
14+@@ -203,7 +203,7 @@ suffixName ident symb n =
49 -- convert a number into both alphanumeric and symoblic forms
15 -- convert a number into both alphanumeric and symoblic forms
50 uniquePrefixes :: String -- alphanumeric prefix
16 uniquePrefixes :: String -- alphanumeric prefix
51 -> String -- symbolic prefix
17 -> String -- symbolic prefix