
I would like to propose the elimination of the special error case gcd 0 0 = error "Prelude.gcd: gcd 0 0 is undefined" to replace it with gcd 0 0 = 0 (which would be an automatic consequence of removing the above line). Rationale: 1. It makes gcd a total function. 2. It makes gcd associative. 3. It makes folding gcd over a list safe. 4. It conforms to common mathematical practice: In a commutative ring, a greatest common divisor of two elements a, b is a common divisor g of a and b such that every common divisor d of a and b also divides g (if R is a commutative ring, a \in R, d \in R is a divisor of a iff there exists c \in R with a = d*c [leaving out noncommutative rings for simplicity]). Since every ring element divides 0, the above definition entails gcd 0 0 = 0. Further, in a principal ideal ring, the greatest common divisors of two elements a and b are the generators of the ideal (a,b), again that characterisation of greatest common divisors says gcd 0 0 = 0: (0,0) = {0} = (0). Pros: see above. Cons: ? I'm not aware of any, the change shouldn't break existing code, since that would have to check for the special case anyway. Daniel

+1 Jacques On 09/05/2011 6:49 PM, Daniel Fischer wrote:
I would like to propose the elimination of the special error case
gcd 0 0 = error "Prelude.gcd: gcd 0 0 is undefined"
to replace it with
gcd 0 0 = 0
(which would be an automatic consequence of removing the above line).
Rationale:
1. It makes gcd a total function. 2. It makes gcd associative. 3. It makes folding gcd over a list safe. 4. It conforms to common mathematical practice:
In a commutative ring, a greatest common divisor of two elements a, b is a common divisor g of a and b such that every common divisor d of a and b also divides g (if R is a commutative ring, a \in R, d \in R is a divisor of a iff there exists c \in R with a = d*c [leaving out noncommutative rings for simplicity]). Since every ring element divides 0, the above definition entails gcd 0 0 = 0.
Further, in a principal ideal ring, the greatest common divisors of two elements a and b are the generators of the ideal (a,b), again that characterisation of greatest common divisors says gcd 0 0 = 0: (0,0) = {0} = (0).
Pros: see above.
Cons: ? I'm not aware of any, the change shouldn't break existing code, since that would have to check for the special case anyway.
Daniel
_______________________________________________ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime

+1
On 9 May 2011 19:11, Jacques Carette
+1 Jacques
On 09/05/2011 6:49 PM, Daniel Fischer wrote:
I would like to propose the elimination of the special error case
gcd 0 0 = error "Prelude.gcd: gcd 0 0 is undefined"
to replace it with
gcd 0 0 = 0
(which would be an automatic consequence of removing the above line).
Rationale:
1. It makes gcd a total function. 2. It makes gcd associative. 3. It makes folding gcd over a list safe. 4. It conforms to common mathematical practice:
In a commutative ring, a greatest common divisor of two elements a, b is a common divisor g of a and b such that every common divisor d of a and b also divides g (if R is a commutative ring, a \in R, d \in R is a divisor of a iff there exists c \in R with a = d*c [leaving out noncommutative rings for simplicity]). Since every ring element divides 0, the above definition entails gcd 0 0 = 0.
Further, in a principal ideal ring, the greatest common divisors of two elements a and b are the generators of the ideal (a,b), again that characterisation of greatest common divisors says gcd 0 0 = 0: (0,0) = {0} = (0).
Pros: see above.
Cons: ? I'm not aware of any, the change shouldn't break existing code, since that would have to check for the special case anyway.
Daniel
_______________________________________________ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
_______________________________________________ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime

On Mon, May 9, 2011 at 3:49 PM, Daniel Fischer
I would like to propose the elimination of the special error case
gcd 0 0 = error "Prelude.gcd: gcd 0 0 is undefined"
to replace it with
gcd 0 0 = 0
(which would be an automatic consequence of removing the above line).
In my email archives, I found two previous threads on the subject. Both ended up in favor of the proposal: http://www.haskell.org/pipermail/haskell/2001-December/008560.html http://www.haskell.org/pipermail/haskell-cafe/2009-May/060880.html As a result of the latter discussion, a ticket was opened on GHC's trac: http://hackage.haskell.org/trac/ghc/ticket/3304 But it was eventually closed for lack of attention. So if someone actually follows through with this as an official libraries submission (with a patch, deadline, etc.), the odds seem in favor of it. Best, -Judah

On Tuesday 10 May 2011 08:02:50, Judah Jacobson wrote:
On Mon, May 9, 2011 at 3:49 PM, Daniel Fischer
wrote: I would like to propose the elimination of the special error case
gcd 0 0 = error "Prelude.gcd: gcd 0 0 is undefined"
to replace it with
gcd 0 0 = 0
(which would be an automatic consequence of removing the above line).
In my email archives, I found two previous threads on the subject. Both ended up in favor of the proposal: http://www.haskell.org/pipermail/haskell/2001-December/008560.html http://www.haskell.org/pipermail/haskell-cafe/2009-May/060880.html
As a result of the latter discussion, a ticket was opened on GHC's trac: http://hackage.haskell.org/trac/ghc/ticket/3304 But it was eventually closed for lack of attention.
So if someone actually follows through with this as an official libraries submission (with a patch, deadline, etc.), the odds seem in favor of it.
I'll try to see it through, although the process seems rather daunting. It has annoyed me for too long. Patches for GHC are at http://hackage.haskell.org/trac/ghc/ticket/3304 (plural, because the error needs to be in the haskell98 and haskell2010 packages, since the report demands it). Although this time there has not been much discussion yet, I refer to the previous discussions linked by Judah, to conclude that after some discussion (albeit spread over many years), the proposal seems plausible. Following http://hackage.haskell.org/trac/haskell-prime/wiki/Process#Proposals I hereby volunteer to become the proposal owner. Cheers, Daniel

On Wednesday 18 May 2011 03:57:06 I wrote:
Following http://hackage.haskell.org/trac/haskell-prime/wiki/Process#Proposals I hereby volunteer to become the proposal owner.
So, how's this going to continue? It sparked a renewed go at simplifying the libraries proposal process, but since it involves changing the report, I figured that a haskell-prime proposal is necessary and a libraries proposal wouldn't suffice. If it's considered to be a small enough change so a libraries proposal would be sufficient, all the better, but if not, I'd like to pursue the haskell-prime process further. Anyway, some feedback on the status and procedure would be appreciated. Cheers, Daniel

On Wed, May 25, 2011 at 08:24:52PM +0200, Daniel Fischer wrote:
If it's considered to be a small enough change so a libraries proposal would be sufficient, all the better, but if not, I'd like to pursue the haskell-prime process further.
My understanding is that for changes to libraries mentioned in the language report, we use the libraries@ process, not the H' process. Thanks Ian

But see http://www.haskell.org/haskellwiki/Library_submissions/NewDraft for a proposal for updating the core-libraries process. Simon | -----Original Message----- | From: haskell-prime-bounces@haskell.org [mailto:haskell-prime-bounces@haskell.org] On | Behalf Of Ian Lynagh | Sent: 25 May 2011 23:48 | To: haskell-prime@haskell.org | Subject: Re: Proposal: Make gcd total | | On Wed, May 25, 2011 at 08:24:52PM +0200, Daniel Fischer wrote: | > | > If it's considered to be a small enough change so a libraries proposal | > would be sufficient, all the better, but if not, I'd like to pursue the | > haskell-prime process further. | | My understanding is that for changes to libraries mentioned in the | language report, we use the libraries@ process, not the H' process. | | | Thanks | Ian | | | _______________________________________________ | Haskell-prime mailing list | Haskell-prime@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-prime

+1 On Tue, May 10, 2011 at 12:49 AM, Daniel Fischer < daniel.is.fischer@googlemail.com> wrote:
I would like to propose the elimination of the special error case
gcd 0 0 = error "Prelude.gcd: gcd 0 0 is undefined"
to replace it with
gcd 0 0 = 0
(which would be an automatic consequence of removing the above line).
Rationale:
1. It makes gcd a total function. 2. It makes gcd associative. 3. It makes folding gcd over a list safe. 4. It conforms to common mathematical practice:
In a commutative ring, a greatest common divisor of two elements a, b is a common divisor g of a and b such that every common divisor d of a and b also divides g (if R is a commutative ring, a \in R, d \in R is a divisor of a iff there exists c \in R with a = d*c [leaving out noncommutative rings for simplicity]). Since every ring element divides 0, the above definition entails gcd 0 0 = 0.
Further, in a principal ideal ring, the greatest common divisors of two elements a and b are the generators of the ideal (a,b), again that characterisation of greatest common divisors says gcd 0 0 = 0: (0,0) = {0} = (0).
Pros: see above.
Cons: ? I'm not aware of any, the change shouldn't break existing code, since that would have to check for the special case anyway.
Daniel
_______________________________________________ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
participants (7)
-
Cale Gibbard
-
Daniel Fischer
-
Ian Lynagh
-
Jacques Carette
-
Judah Jacobson
-
Sebastian Fischer
-
Simon Peyton-Jones