[commit: integer-simple] master: Don't define our own list type (44dd630)
Ian Lynagh
igloo at earth.li
Sun Sep 18 00:28:04 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/integer-simple
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/44dd630632f47bec3693ea9a22a896edfad15fd7
>---------------------------------------------------------------
commit 44dd630632f47bec3693ea9a22a896edfad15fd7
Author: Ian Lynagh <igloo at earth.li>
Date: Sat Sep 17 18:23:16 2011 +0100
Don't define our own list type
We can now use [] as it has been moved to ghc-prim.
>---------------------------------------------------------------
GHC/Integer/Type.hs | 15 ++++++---------
1 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/GHC/Integer/Type.hs b/GHC/Integer/Type.hs
index f5cdea3..8bc530a 100644
--- a/GHC/Integer/Type.hs
+++ b/GHC/Integer/Type.hs
@@ -42,15 +42,12 @@ data Integer = Positive !Positive | Negative !Positive | Naught
-- Positive's have the property that they contain at least one Bit,
-- and their last Bit is One.
type Positive = Digits
-type Positives = List Positive
+type Positives = [Positive]
data Digits = Some !Digit !Digits
| None
type Digit = Word#
--- XXX Could move [] above us
-data List a = Nil | Cons a (List a)
-
mkInteger :: Bool -- non-negative?
-> [Int] -- absolute value in 31 bit chunks, least significant first
-- ideally these would be Words rather than Ints, but
@@ -743,9 +740,9 @@ quotRemPositive :: Positive -> Positive -> (# Integer, Integer #)
subtractors = mkSubtractors (WORD_SIZE_IN_BITS# -# 1#)
mkSubtractors (!n) = if n ==# 0#
- then Cons ys Nil
- else Cons (ys `smallShiftLPositive` n)
- (mkSubtractors (n -# 1#))
+ then [ys]
+ else (ys `smallShiftLPositive` n)
+ : (mkSubtractors (n -# 1#))
-- The main function. Go the the end of xs, then walk
-- back trying to divide the number we accumulate by ys.
@@ -761,8 +758,8 @@ quotRemPositive :: Positive -> Positive -> (# Integer, Integer #)
(# some d ds, m'' #)
g :: Digit -> Positives -> Digits -> (# Digit, Digits #)
- g (!d) Nil (!m) = (# d, m #)
- g (!d) (Cons sub subs) (!m)
+ g (!d) [] (!m) = (# d, m #)
+ g (!d) (sub : subs) (!m)
= case d `uncheckedShiftL#` 1# of
d' ->
case m `comparePositive` sub of
More information about the Cvs-libraries
mailing list