From 44dd630632f47bec3693ea9a22a896edfad15fd7 Mon Sep 17 00:00:00 2001 From: Ian Lynagh <igloo@earth.li> Date: Sat, 17 Sep 2011 18:23:16 +0100 Subject: [PATCH] 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 file 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 -- GitLab