Skip to content
Snippets Groups Projects
Commit 34e290a0 authored by daniel.is.fischer's avatar daniel.is.fischer Committed by Ian Lynagh
Browse files

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.
parent eb655b03
No related branches found
No related tags found
No related merge requests found
...@@ -151,7 +151,8 @@ import GHC.Base ...@@ -151,7 +151,8 @@ import GHC.Base
import Text.Read import Text.Read
import GHC.Enum import GHC.Enum
import GHC.Num import GHC.Num
import GHC.Real import GHC.Real hiding ( gcd )
import qualified GHC.Real ( gcd )
import GHC.Float import GHC.Float
import GHC.Show import GHC.Show
import GHC.Err ( undefined ) import GHC.Err ( undefined )
...@@ -207,3 +208,11 @@ seq _ y = y ...@@ -207,3 +208,11 @@ seq _ y = y
catch :: IO a -> (IOError -> IO a) -> IO a catch :: IO a -> (IOError -> IO a) -> IO a
catch = New.catch 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment