> I'm with Jon Fairbairn on this. Negative arguments are an error
> because the domain of take and drop is the naturals. The problem
> is that we use Int to represent naturals. -- P
Yep, this is exactly the same argument we had about this
a year or two ago, Phil. My attitude about the "implicit Nat"
argument is the same as it was then -- if you want the functions
to be over Nat's then *say* Nat in the type, not Int. This
could be done in at least two relatively lightweight ways.
-- provide a Nat type that maps to unsigned integers
-- provide a simple type synonym
type Nat = Int
along with a prominent comment that any function that
*says* Nat in its type should raise an error on a negative argument
I would have no arguments with either approach, or with any other
approach that makes Nat explicit in the type.
But if the type *says* Int, then it should have reasonable behavior
for ints. I look at the negative case as being equivalent to
standard mathematical treatment of ranges such as i..j, where the
range is considered to be empty if j < i. Allowing take/drop to
handle negative arguments should be useful to exactly the same
extent as that mathematical convention.
Chris
- RE: drop & take [was: fixing typos in Haskel... S. Alexander Jacobson
- Re: drop & take [was: fixing typos in H... Dr. Mark E. Hall
- RE: drop & take [was: fixing typos in Haskel... Simon Peyton-Jones
- Re: drop & take [was: fixing typos in H... Ola Fosheim Gr�stad
- Re: drop & take [was: fixing typos ... Pablo E. Martinez Lopez
- Re: drop & take [was: fixing ty... Ola Fosheim Gr�stad
- Re: drop & take [was: fixing typos in Haskel... Chris Okasaki
- Re: drop & take [was: fixing typos in H... Tommy Thorn
- Re: drop & take [was: fixing typos in H... Philip Wadler
- Re: drop & take [was: fixing typos ... Joe Fasel
- Re: drop & take [was: fixing typos ... Chris Okasaki
- Re: drop & take [was: fixing ty... Philip Wadler
- Re: drop & take [was: fixing ty... Joe Fasel
- Re: drop & take [was: fixing ty... Fergus Henderson
- Re: drop & take [was: fixing typos in H... D. Tweed
- Re: drop & take [was: fixing typos in H... Matt Harden
- RE: drop & take [was: fixing typos in Haskel... Roberto E. Lublinerman
- Re: drop & take [was: fixing typos in Haskel... Marcin 'Qrczak' Kowalczyk
- Re: drop & take [was: fixing typos in H... Hamilton Richards
- Re: drop & take [was: fixing typos ... Ch. A. Herrmann
