Skip to content

Instantly share code, notes, and snippets.

@leoncamel

leoncamel/a.diff

Created Jun 23, 2012
Embed
What would you like to do?
diff --git a/GHC/Integer.hs b/GHC/Integer.hs
index c9b50a7..8fd41d9 100644
--- a/GHC/Integer.hs
+++ b/GHC/Integer.hs
@@ -28,6 +28,7 @@ module GHC.Integer (
eqInteger, neqInteger, absInteger, signumInteger,
leInteger, gtInteger, ltInteger, geInteger, compareInteger,
divModInteger, quotRemInteger, quotInteger, remInteger,
+ modInteger, divInteger,
encodeFloatInteger, decodeFloatInteger, floatFromInteger,
encodeDoubleInteger, decodeDoubleInteger, doubleFromInteger,
-- gcdInteger, lcmInteger, -- XXX
diff --git a/GHC/Integer/Type.hs b/GHC/Integer/Type.hs
index c3d812c..f2efcd5 100644
--- a/GHC/Integer/Type.hs
+++ b/GHC/Integer/Type.hs
@@ -398,6 +398,18 @@ remInteger :: Integer -> Integer -> Integer
x `remInteger` y = case x `quotRemInteger` y of
(# _, r #) -> r
+{-# NOINLINE modInteger #-}
+modInteger :: Integer -> Integer -> Integer
+n `modInteger` d =
+ case n `divModInteger` d of
+ (# _, r #) -> r
+
+{-# NOINLINE divInteger #-}
+divInteger :: Integer -> Integer -> Integer
+n `divInteger` d =
+ case n `divModInteger` d of
+ (# q, _ #) -> q
+
{-# NOINLINE compareInteger #-}
compareInteger :: Integer -> Integer -> Ordering
Positive x `compareInteger` Positive y = x `comparePositive` y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.