[Haskell-cafe] Re: Perl-style numeric type
Brent Yorgey
byorgey at gmail.com
Wed Jun 20 11:36:29 EDT 2007
On 6/19/07, Brent Yorgey <byorgey at gmail.com> wrote:
>
> I've started developing a library to support a "Perl-style" numeric type
> that "does the right thing" without having to worry too much about types...
So, I just completed my implementation and decided to test it out by
converting a simple program I wrote the other day (which exhibited lots of
fromIntegers and such) to use my generic number type. When I was done
converting, the code looked much simpler, which was nice. It type-checked
and compiled just fine. And... didn't work. After a number of minutes of
fiddling around, I finally realized that something which I "knew" was an
integer was actually being represented as a Double internally due to some
operator I had used previously, which was causing the isSquare function to
always return False (equality of floating-point numbers and all that =P ).
Adding a call to "round" fixed it, BUT I sheepishly realized that yes, I had
just spent five minutes tracking down a bug that the type checker would have
found for me had I not worked so hard to do stuff behind its back.
Consider me chastened! *goes off to contribute to that wiki page that
Henning started...*
-Brent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070620/d4515b52/attachment.htm
More information about the Haskell-Cafe
mailing list