> 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



Reply via email to