From 34e290a011f2df676a5d655438999634f261502c Mon Sep 17 00:00:00 2001 From: Daniel Fischer <daniel.is.fischer@googlemail.com> Date: Tue, 17 May 2011 23:01:47 +0200 Subject: [PATCH] Add old behaviour of gcd The behaviour of gcd was changed to "gcd 0 0 = 0", here we must keep the haskell98 behaviour and raise an error. --- Prelude.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Prelude.hs b/Prelude.hs index a09a300..44342a0 100644 --- a/Prelude.hs +++ b/Prelude.hs @@ -151,7 +151,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 ) @@ -207,3 +208,11 @@ 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@. @'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 -- GitLab