id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,os,architecture,failure,testcase,blockedby,blocking,related,differential
3304,define gcd 0 0 = 0,stevec,,"Please make any comments on the libraries list by Tuesday 15th September 2009.
A suggestion to change 'gcd 0 0' from[[BR]]
gcd 0 0 = error ""Prelude.gcd: gcd 0 0 is undefined""[[BR]]
to[[BR]]
gcd 0 0 = 0
The proposal has been discussed on haskell-cafe@haskell.org
http://www.haskell.org/pipermail/haskell-cafe/2009-May/060788.html
and there was a lot of support for the suggested change.
Current code:
libraries/base/GHC/Real.lhs
{{{
-- | @'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 = gcd' (abs x) (abs y)
where gcd' a 0 = a
gcd' a b = gcd' b (a `rem` b)
}}}
Suggested code:
{{{
-- | @'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@ is defined to be 0.
gcd :: (Integral a) => a -> a -> a
gcd x y = gcd' (abs x) (abs y)
where gcd' a 0 = a
gcd' a b = gcd' b (a `rem` b)
}}}
[Note: I tried following the instructions at
http://www.haskell.org/haskellwiki/Library_submissions
to create a darcs patch. I successfully downloaded a copy of HEAD, but was unable to create a patch:
$ darcs record libraries/base/GHC/Real.lhs
Recording changes in ""libraries/base/GHC/Real.lhs"":
No changes in selected files or directories!
I would claim that the instructions are insufficient for a darcs beginner.
]",proposal,closed,normal,7.2.1,libraries/base,7.1,fixed,,libraries@… gale@… asr daniel.is.fischer@… hvr ekmett,Unknown/Multiple,Unknown/Multiple,None/Unknown,,,,,