| I like symmetry arguments---but as a compiler writer I also 
| have another reason to vote for take and drop to work on negative
arguments.  It
| allows me to write foldr definitions (which I can deforest, 
| reason about equationally, etc.) without having to scribble down a side
condition!

Well this one really seems to have woken up the Haskell list!

* I do not intend to change the behaviour of take/drop on arguments
  that are too big.  The only question is what to do for negative args.

* Opinion seems pretty evenly balanced between 
        (A) Accept negative arg (take yields [], drop yields xs)
        (B) Fail on negative arg

* I do not believe that anyone really feels strongly about
  (A) vs (B), although lots of people have an opinion. 
  Tell me if I've misunderstood.


I'll continue to listen for a while, but I'm tending towards (A).
My reasons:

- I like symmetry

- take n xs ++ drop n xs = xs, regardless of n

- We also get that drop can be defined as
        reverse, then take, then reverse

        drop n xs = reverse (take (length xs - n) (reverse xs))

  This law requires the 0/length xs symmetry

- take and drop can be described by a foldr
        take n xs = foldr k (\_ -> []) xs n
                  where
                     k x f n | n <= 0 = []
                              | otherwise = x : f (n-1)

- I'm not greatly persuaded by the Nat argument; if you
  like, take/drop collapse Int onto Nat and then do their
  thing.


Simon

Reply via email to