[commit: haskell2010] master: Add old behaviour of gcd (d9d14b4)
Ian Lynagh
igloo at earth.li
Sun Jun 12 17:22:28 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/haskell2010
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/d9d14b4ee8e8af1eb20d9b49d12c6947f780ac6a
>---------------------------------------------------------------
commit d9d14b4ee8e8af1eb20d9b49d12c6947f780ac6a
Author: Daniel Fischer <daniel.is.fischer at googlemail.com>
Date: Tue May 17 23:04:35 2011 +0200
Add old behaviour of gcd
The behaviour of gcd was changed to "gcd 0 0 = 0", here we must keep
the haskell2010 behaviour and raise an error.
>---------------------------------------------------------------
Prelude.hs | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/Prelude.hs b/Prelude.hs
index 38cb3b4..9be6ccf 100644
--- a/Prelude.hs
+++ b/Prelude.hs
@@ -150,7 +150,8 @@ import GHC.Base
import Text.Read
import GHC.Enum
import GHC.Num
-import GHC.Real
+import GHC.Real hiding ( gcd )
+import qualified GHC.Real ( gcd )
import GHC.Float
import GHC.Show
import GHC.Err ( undefined )
@@ -206,3 +207,12 @@ seq _ y = y
catch :: IO a -> (IOError -> IO a) -> IO a
catch = New.catch
+#ifdef __GLASGOW_HASKELL__
+-- | @'gcd' x y@ is the greatest (positive) integer that divides both @x@
+-- and @y@; for example @'gcd' (-3) 6@ = @3@, @'gcd' (-3) (-6)@ = @3@,
+-- @'gcd' 0 4@ = @4 at . @'gcd' 0 0@ raises a runtime error.
+gcd :: (Integral a) => a -> a -> a
+gcd 0 0 = error "Prelude.gcd: gcd 0 0 is undefined"
+gcd x y = GHC.Real.gcd x y
+#endif
+
More information about the Cvs-libraries
mailing list