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

Balazs Komuves bkomuves at gmail.com
Mon Oct 17 21:22:25 CEST 2011


On Mon, Oct 17, 2011 at 8:05 PM, Tyson Whitehead <twhitehead at gmail.com>wrote:

> On October 13, 2011 18:47:48 Paterson, Ross wrote:
>
> > Fractional would be superfluous, but people would probably still want
> > to overload abs, signum, toRational, quot, rem and toInteger for the
> > standard numeric types.  Maybe the classes would have different names.
>
> Thanks for getting back to me on this Ross.  I was also wondering about
> putting fromInteger and fromRational in Ring and Field.
>
> I would have imagined that not all rings and fields would have reasonable
> injections from the set of integers and rational numbers.
>
> Is this not the case?
>
> Thanks!  -Tyson
>

Rings with unity have a canonical map, actually a ring homomorphism (but not

necessarily injection) from the integers, namely for the natural integer N,
you
add together the unit element with itself N times. For negative N, you take
the
additive inverse.

For fields, you would try to extend this to rationals; however, it seems
that because
of the non-injectivity of the above, this won't always work. Example: finite
fields.
In a finite field of order P, we would have f(N/P) = f(N)/f(P) = f(N)/0
which is not defined.

So, unless I made some stupid mistake, fromInteger in Ring is OK, but
fromRational in Field is not.

However it probably would make sense to separate rings with unity from
rings without unity, and put fromInteger in the former class.

Balazs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20111017/ab8e2caf/attachment.htm>


More information about the Libraries mailing list