YAP (was Re: Proposal: Remove Show and Eq superclasses of Num)

Paterson, Ross R.Paterson at city.ac.uk
Fri Nov 4 00:16:50 CET 2011


Balazs Komuves writes:
> It seems to me that a typical Euclidean domain does not have any kind of
> meaningful canonical associate / unit map. Examples:
>
> - The Gaussian integers Z[i] (units are 1,-1,i,-i; what would be the associated element of 5+7i ?)

Prelude Data.Algebra Data.Complex> associate (5 :+ 7) :: Complex Integer
5 :+ 7
Prelude Data.Algebra Data.Complex> unit (5 :+ 7) :: Complex Integer
1 :+ 0
Prelude Data.Algebra Data.Complex> associate (5 :+ (-7)) :: Complex Integer
7 :+ 5
Prelude Data.Algebra Data.Complex> unit (5 :+ (-7)) :: Complex Integer
0 :+ (-1)

Doing it by quadrants seems a reasonable choice.  It's arbitrary to some
extent, but then so are div and mod on Gaussian integers.  But when we
write a function (e.g. gcd), we have to provide _an_ answer, even it's
not distinguished in some obvious way.



More information about the Libraries mailing list