[commit: integer-gmp] master: Add another gcdInteger rule (4b780b9)

Ian Lynagh <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.libraries
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/packages/integer-gmp

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/4b780b93beac863b7945d7e050ffa6cdaf256eb7

>---------------------------------------------------------------

commit 4b780b93beac863b7945d7e050ffa6cdaf256eb7
Author: Ian Lynagh <[email protected]>
Date:   Fri Jul 13 20:04:51 2012 +0100

    Add another gcdInteger rule
    
    This one is better when the result is converted to an Int

>---------------------------------------------------------------

 GHC/Integer/Type.lhs |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/GHC/Integer/Type.lhs b/GHC/Integer/Type.lhs
index a402f37..b9d9c3c 100644
--- a/GHC/Integer/Type.lhs
+++ b/GHC/Integer/Type.lhs
@@ -283,9 +283,14 @@ lcmInteger a b =      if a `eqInteger` S# 0# then S# 0#
         ab = absInteger b
 
 -- This rule needs to use absInteger so that it works correctly when
--- the result is minBound :: Int
-{-# RULES "gcdInteger/Int" forall a b.
-    gcdInteger (smallInteger a) (smallInteger b) = absInteger (smallInteger (gcdInt a b))
+-- the result is minBound :: Int. But that isn't necessary when the
+-- result is converted to an Int.
+{-# RULES
+"gcdInteger/Int" forall a b.
+    gcdInteger (smallInteger a) (smallInteger b)
+        = absInteger (smallInteger (gcdInt a b))
+"integerToInt/gcdInteger/Int" forall a b.
+    integerToInt (gcdInteger (smallInteger a) (smallInteger b)) = gcdInt a b
   #-}
 gcdInt :: Int# -> Int# -> Int#
 gcdInt 0# y  = absInt y
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.