@@ -28,27 +28,35 @@ import Data.Text.Internal.Builder.Int.Digits (digits)
28
28
import Data.Text.Array
29
29
import Data.Word (Word , Word8 , Word16 , Word32 , Word64 )
30
30
import GHC.Base (quotInt , remInt )
31
- import GHC.Num ( quotRemInteger )
31
+ import GHC.Types ( Int ( .. ) )
32
32
import Control.Monad.ST
33
33
#if MIN_VERSION_base(4,11,0)
34
34
import Prelude hiding ((<>) )
35
35
#endif
36
36
37
37
#ifdef __GLASGOW_HASKELL__
38
+
39
+ #if __GLASGOW_HASKELL__ >= 811
40
+
41
+ import GHC.Num.Integer
42
+ #define HAS_INTEGER_CONSTR 1
43
+ #define quotRemInteger integerQuotRem#
44
+
45
+ #else
46
+
47
+ import GHC.Num (quotRemInteger )
48
+
38
49
# if defined(INTEGER_GMP)
39
50
import GHC.Integer.GMP.Internals (Integer (S #))
40
- import GHC.Types (Int (I #))
51
+ #define IS S#
52
+ #define HAS_INTEGER_CONSTR 1
41
53
# elif defined(INTEGER_SIMPLE)
42
54
import GHC.Integer ()
43
55
# else
44
56
# error "You need to use either GMP or integer-simple."
45
57
# endif
46
58
#endif
47
59
48
- #if defined(INTEGER_GMP) || defined(INTEGER_SIMPLE)
49
- # define PAIR(a,b) (# a,b #)
50
- #else
51
- # define PAIR(a,b) (a,b)
52
60
#endif
53
61
54
62
decimal :: Integral a => a -> Builder
@@ -199,9 +207,9 @@ hexDigit n
199
207
data T = T ! Integer ! Int
200
208
201
209
integer :: Int -> Integer -> Builder
202
- #ifdef INTEGER_GMP
203
- integer 10 (S # i# ) = decimal (I # i# )
204
- integer 16 (S # i# ) = hexadecimal (I # i# )
210
+ #ifdef HAS_INTEGER_CONSTR
211
+ integer 10 (IS i# ) = decimal (I # i# )
212
+ integer 16 (IS i# ) = hexadecimal (I # i# )
205
213
#endif
206
214
integer base i
207
215
| i < 0 = singleton ' -' <> go (- i)
@@ -215,12 +223,12 @@ integer base i
215
223
| otherwise = splith p (splitf (p* p) n)
216
224
217
225
splith p (n: ns) = case n `quotRemInteger` p of
218
- PAIR ( q,r) | q > 0 -> q : r : splitb p ns
226
+ ( # q,r # ) | q > 0 -> q : r : splitb p ns
219
227
| otherwise -> r : splitb p ns
220
228
splith _ _ = error " splith: the impossible happened."
221
229
222
230
splitb p (n: ns) = case n `quotRemInteger` p of
223
- PAIR ( q,r) -> q : r : splitb p ns
231
+ ( # q,r # ) -> q : r : splitb p ns
224
232
splitb _ _ = []
225
233
226
234
T maxInt10 maxDigits10 =
@@ -238,15 +246,15 @@ integer base i
238
246
| otherwise = maxDigits16
239
247
240
248
putH (n: ns) = case n `quotRemInteger` maxInt of
241
- PAIR ( x,y)
249
+ ( # x,y # )
242
250
| q > 0 -> int q <> pblock r <> putB ns
243
251
| otherwise -> int r <> putB ns
244
252
where q = fromInteger x
245
253
r = fromInteger y
246
254
putH _ = error " putH: the impossible happened"
247
255
248
256
putB (n: ns) = case n `quotRemInteger` maxInt of
249
- PAIR ( x,y) -> pblock q <> pblock r <> putB ns
257
+ ( # x,y # ) -> pblock q <> pblock r <> putB ns
250
258
where q = fromInteger x
251
259
r = fromInteger y
252
260
putB _ = Data.Monoid. mempty
0 commit comments