Ticket #3304: 0001-Add-old-behaviour-of-gcd-h98.patch

File 0001-Add-old-behaviour-of-gcd-h98.patch, 1.2 KB (added by daniel.is.fischer, 3 years ago)

haskell98

  • Prelude.hs

    From 7a4246791fb14ca63bb23fd7f7b2d8cf6a9a4b2f 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 files changed, 10 insertions(+), 1 deletions(-)
    
    diff --git a/Prelude.hs b/Prelude.hs
    index a09a300..44342a0 100644
    a b import GHC.Base 
    151151import Text.Read 
    152152import GHC.Enum 
    153153import GHC.Num 
    154 import GHC.Real 
     154import GHC.Real hiding ( gcd ) 
     155import qualified GHC.Real ( gcd ) 
    155156import GHC.Float 
    156157import GHC.Show 
    157158import GHC.Err   ( undefined ) 
    seq _ y = y 
    207208catch :: IO a -> (IOError -> IO a) -> IO a 
    208209catch = New.catch 
    209210 
     211#ifdef __GLASGOW_HASKELL__ 
     212-- | @'gcd' x y@ is the greatest (positive) integer that divides both @x@ 
     213-- and @y@; for example @'gcd' (-3) 6@ = @3@, @'gcd' (-3) (-6)@ = @3@, 
     214-- @'gcd' 0 4@ = @4@.  @'gcd' 0 0@ raises a runtime error. 
     215gcd             :: (Integral a) => a -> a -> a 
     216gcd 0 0         =  error "Prelude.gcd: gcd 0 0 is undefined" 
     217gcd x y         = GHC.Real.gcd x y 
     218#endif