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

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

haskell2010

  • Prelude.hs

    From b9e6c5cba6366dafd8b05be722a4df814bd80f5f Mon Sep 17 00:00:00 2001
    From: Daniel Fischer <[email protected]>
    Date: Tue, 17 May 2011 23:04:35 +0200
    Subject: [PATCH] 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 b import GHC.Base 
    150150import Text.Read
    151151import GHC.Enum
    152152import GHC.Num
    153 import GHC.Real
     153import GHC.Real hiding ( gcd )
     154import qualified GHC.Real ( gcd )
    154155import GHC.Float
    155156import GHC.Show
    156157import GHC.Err   ( undefined )
    seq _ y = y 
    206207catch :: IO a -> (IOError -> IO a) -> IO a
    207208catch = New.catch
    208209
     210#ifdef __GLASGOW_HASKELL__
     211-- | @'gcd' x y@ is the greatest (positive) integer that divides both @x@
     212-- and @y@; for example @'gcd' (-3) 6@ = @3@, @'gcd' (-3) (-6)@ = @3@,
     213-- @'gcd' 0 4@ = @4@.  @'gcd' 0 0@ raises a runtime error.
     214gcd             :: (Integral a) => a -> a -> a
     215gcd 0 0         =  error "Prelude.gcd: gcd 0 0 is undefined"
     216gcd x y         = GHC.Real.gcd x y
     217#endif
     218