Re: drop take [was: fixing typos in Haskell-98]

2000-01-28 Thread Jan Kort
Marcin 'Qrczak' Kowalczyk wrote: My preference is still (B). (A) is not *very* bad, but should really replicate (-7) "foo" be []? Mine too. Actually after writing my own version of "drop" it turns out that in my case n 0 is a programmer error and n length xs a user error. So what you end up

Re: drop take [was: fixing typos in Haskell-98]

2000-01-26 Thread Hamilton Richards
The take-drop law I've always liked is take n xs ++ drop n xs = xs, for all lists xs and all naturals n. I agree that (take n _) and (drop n _) should both give errors for n 0. On the other hand, I don't buy the argument that (take 1 []) should be undefined because (head []) is

Re: drop take [was: fixing typos in Haskell-98]

2000-01-26 Thread Ch. A. Herrmann
"Hamilton" == Hamilton Richards [EMAIL PROTECTED] writes: Hamilton How about these definitions? They're like the Haskell98 Hamilton prelude definitions except that n0 is always an error, Hamilton even if the list is []. the problem with an unnecessary restriction is that it

Re: drop take [was: fixing typos in Haskell-98]

2000-01-26 Thread Marcin 'Qrczak' Kowalczyk
Tue, 25 Jan 2000 14:41:54 -0800, Craig Dickson [EMAIL PROTECTED] pisze: And I like having "head []" be an error, because if it returned [], then it seems to me that that would have nasty implications for pattern-matching. head [] can't return anything than bottom because anything else has

Re: drop take [was: fixing typos in Haskell-98]

2000-01-26 Thread Marcin 'Qrczak' Kowalczyk
Tue, 25 Jan 2000 15:33:25 -0800, Craig Dickson [EMAIL PROTECTED] pisze: If "(x:xs)" does not match [], then the reason for this should be that [] has no head to bind to x, nor tail to bind to xs; No, the reason is simply that [] and (:) are distinct constructors. E.g. the pattern Nothing

Re: drop take [was: fixing typos in Haskell-98]

2000-01-26 Thread Marcin 'Qrczak' Kowalczyk
Wed, 26 Jan 2000 16:16:39 +0100 (MET), Ch. A. Herrmann [EMAIL PROTECTED] pisze: the problem with an unnecessary restriction is that it complicates reasoning about the program. Instead of xs = { take/drop-law } take (n-m) xs ++ drop (n-m) xs you have to write, e.g.: xs

Re: drop take [was: fixing typos in Haskell-98]

2000-01-26 Thread Pablo E. Martinez Lopez
Many properties are broken anyway in presence of negative arguments drop n . drop m = drop (n+m) -- try n = -1, m = 1 take n . drop m = drop m . take (n+m) -- try n = 1, m = -1 But following Simon assumption about collapsing integers to naturals, you can have collapse n | n0 = 0

RE: drop take [was: fixing typos in Haskell-98]

2000-01-26 Thread Brian Boutel
On Thursday, January 27, 2000 2:08 PM, Frank A. Christoph [SMTP:[EMAIL PROTECTED]] wrote: My preference is still (B). (A) is not *very* bad, but should really replicate (-7) "foo" be []? I could say: Sure, why not? replicate suffers from the same domain problem as take/drop. This was not

RE: drop take [was: fixing typos in Haskell-98]

2000-01-26 Thread Frank A. Christoph
Brian Boutel wrote: On Thursday, January 27, 2000 2:08 PM, Frank A. Christoph [SMTP:[EMAIL PROTECTED]] wrote: My preference is still (B). (A) is not *very* bad, but should really replicate (-7) "foo" be []? I could say: Sure, why not? replicate suffers from the same domain problem as

RE: drop take [was: fixing typos in Haskell-98]

2000-01-25 Thread Simon Peyton-Jones
| Why not do what python does? Thanks for an interesting suggestion, Alex! However, we are in typo-fixing mode here. In the interests of helping this discussion converge I'm going to exercise my dictatorial powers. Though Alex's suggestion has its attractions, I judge it too big a change to

Re: drop take [was: fixing typos in Haskell-98]

2000-01-25 Thread Tommy Thorn
Chris Okasaki wrote: For the people that share this sentiment, can you please explain why ints that are too big should not similarly give an error? I can see both being ok, or both being errors. I just don't see why one should be ok and the other an error. IMHO, both should be errors.

Re: drop take [was: fixing typos in Haskell-98]

2000-01-25 Thread D. Tweed
On Tue, 25 Jan 2000, Chris Okasaki wrote: I'm with the option (B): negatives are just outside the domain of takedrop, and should give you an error message. For the people that share this sentiment, can you please explain why ints that are too big should not similarly give an error?

Re: drop take [was: fixing typos in Haskell-98]

2000-01-25 Thread D. Tweed
On Tue, 25 Jan 2000, D. Tweed wrote: Oops, fixing two thinko's f _ [] = [] f a xs =res:f a' zs (ys,zs)=splitAt 40 xs (a',res)=doStuff a ys (My haskell coding is getting worse than my C++, which I didn't believe possible...)

Re: drop take [was: fixing typos in Haskell-98]

2000-01-25 Thread Joe Fasel
Phil Wadler writes: | 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 | | For the people that share this sentiment, can you please | explain why ints that are

Re: drop take [was: fixing typos in Haskell-98]

2000-01-25 Thread Chris Okasaki
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

Re: drop take [was: fixing typos in Haskell-98]

2000-01-25 Thread Philip Wadler
Chris, I admit your argument about symmetry is attractive. If you could put forward a concrete application, on a par with the `break into blocks' application given earlier, you would likely sway me. -- P

Re: drop take [was: fixing typos in Haskell-98]

2000-01-25 Thread Joe Fasel
Chris Okasaki writes: | 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 |

Re: fixing typos in Haskell-98

2000-01-25 Thread George Russell
(sorry, can't remember the original author) | The correct definitions would be: | | take -2 -- drops the last 2 elements from the list | (takes everything except the last 2 elements) | drop -2 -- grabs the last 2 elements from the list | (drops everything except

Re: drop take [was: fixing typos in Haskell-98]

2000-01-25 Thread Marcin 'Qrczak' Kowalczyk
Tue, 25 Jan 2000 12:14:29 -0500 (EST), Chris Okasaki [EMAIL PROTECTED] pisze: 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 can't agree with

RE: drop take [was: fixing typos in Haskell-98]

2000-01-25 Thread Brian Boutel
On Wednesday, January 26, 2000 9:12 AM, Joe Fasel [SMTP:[EMAIL PROTECTED]] wrote: The call some have made for the tightest possible error checking also has merit, however. That would suggest these definitions: takeExactly 0 _ = [] takeExactly (n+1) (x:xs) = x : takeExactly n xs

Re: drop take [was: fixing typos in Haskell-98]

2000-01-25 Thread Tom Pledger
Hi. For H98, I prefer option (A). Option (B) gives an arbitrary dissimilarity with rangeSize and enumFromTo. They currently match the standard mathematical treatment of ranges such as i..j, which Chris Okasaki mentioned. I'm not saying that they're sacred, just that a shift to the style of

Re: drop take [was: fixing typos in Haskell-98]

2000-01-25 Thread Craig Dickson
Brian Boutel [EMAIL PROTECTED] wrote: We have seen various proposals about what laws should hold wrt take and drop. I think there is a reasonable presumption that the following very simple laws should hold first: length (take n xs) === n length (drop n xs) === length xs -n Does that not

Re: drop take [was: fixing typos in Haskell-98]

2000-01-25 Thread Craig Dickson
Tom Pledger [EMAIL PROTECTED] wrote: Craig Dickson writes: [...] I don't want a pattern like "(x:xs)" to match the empty list, which it presumably would if "head []" and "tail []" did not fail (x and xs would both be bound to []). I don't think it would. Patterns involve data

Re: drop take [was: fixing typos in Haskell-98]

2000-01-25 Thread Matt Harden
Chris Okasaki wrote: I'm with the option (B): negatives are just outside the domain of takedrop, and should give you an error message. For the people that share this sentiment, can you please explain why ints that are too big should not similarly give an error? I can see both being

Re: drop take [was: fixing typos in Haskell-98]

2000-01-25 Thread Fergus Henderson
On 25-Jan-2000, Craig Dickson [EMAIL PROTECTED] wrote: Brian Boutel [EMAIL PROTECTED] wrote: We have seen various proposals about what laws should hold wrt take and drop. I think there is a reasonable presumption that the following very simple laws should hold first: length (take n

Re: drop take [was: fixing typos in Haskell-98]

2000-01-25 Thread Fergus Henderson
On 26-Jan-2000, Brian Boutel [EMAIL PROTECTED] wrote: On Wednesday, January 26, 2000 1:52 PM, Fergus Henderson [SMTP:[EMAIL PROTECTED]] wrote: I agree that it is too big a change for Haskell 98. But I think it would be too big a change for Haskell 2000 too. Making a change like that

fixing typos in Haskell-98

2000-01-24 Thread S.D.Mechveliani
Simon Peyton-Jones [EMAIL PROTECTED] announces the editor's proposals for the "typos" fix in Haskell-98. Partition [..] The "standard" (lazier) defn should be the one in the H98 report. PROPOSAL: use the filter/filter defn of partition I agree. Take and drop [..] I can see three

Re: fixing typos in Haskell-98

2000-01-24 Thread Bjorn Lisper
Take and drop [..] I can see three alternatives: (A) Make them defined for any n. If n 0, do something reasonable: take: give empty list drop: give whole list (B) Make them defined for n length xs, but fail for n 0. (C) Status quo PROPOSAL: Use alternative (A)

Re: fixing typos in Haskell-98

2000-01-24 Thread S. Alexander Jacobson
Why not do what python does? drop -2 -- drops the last 2 elements from the list take -2 -- grabs the last 2 elements from the list take n list | n0 = drop (length list + n) list drop n list | n0 = take (length list + n) list If the list is an infinite list, the behavior is equivalent to B. If

RE: fixing typos in Haskell-98

2000-01-24 Thread Brian Boutel
On Tuesday, January 25, 2000 8:38 AM, S. Alexander Jacobson [SMTP:[EMAIL PROTECTED]] wrote: Why not do what python does? drop -2 -- drops the last 2 elements from the list take -2 -- grabs the last 2 elements from the list take n list | n0 = drop (length list +

RE: fixing typos in Haskell-98

2000-01-24 Thread S. Alexander Jacobson
Ok. so I got it backward. The functionality is still useful and belongs with take and drop. The correct definitions would be: take -2 -- drops the last 2 elements from the list (takes everything except the last 2 elements) drop -2 -- grabs the last 2 elements from the list

drop take [was: fixing typos in Haskell-98]

2000-01-24 Thread Tommy Thorn
S. Alexander Jacobson writes: The correct definitions would be: take -2 -- drops the last 2 elements from the list (takes everything except the last 2 elements) drop -2 -- grabs the last 2 elements from the list (drops everything except the last 2 elements)

Re: fixing typos in Haskell-98

2000-01-24 Thread Craig Dickson
Brian Boutel wrote: take -2 [1,2,3,4] ++ drop -2 [1,2,3,4] - [3,4,1,2] But [1,2,3,4] is NOT the same as [3,4,1,2]. So the equality doesn't hold. Personally, for reasons I'm not sure I can articulate, I've always strongly disliked the notion that negative arguments should produce "backwards"

Re: fixing typos in Haskell-98

2000-01-24 Thread Craig Dickson
anuary 2000 02:39 pm Subject: Re: fixing typos in Haskell-98 Brian Boutel wrote: take -2 [1,2,3,4] ++ drop -2 [1,2,3,4] - [3,4,1,2] But [1,2,3,4] is NOT the same as [3,4,1,2]. So the equality doesn't hold. Personally, for reasons I'm not sure I can articulate, I've always strongly

Re: fixing typos in Haskell-98

2000-01-24 Thread Marcin 'Qrczak' Kowalczyk
Mon, 24 Jan 2000 07:49:30 -0800, Simon Peyton-Jones [EMAIL PROTECTED] pisze: (A) Make them defined for any n. If n 0, do something reasonable: take: give empty list drop: give whole list (B) Make them defined for n length xs, but fail for n 0. I vote for (B) or

Re: drop take [was: fixing typos in Haskell-98]

2000-01-24 Thread Jan Skibinski
All the proposals break this law as well, so I this argument is weak (if not insane :-)) -Alex- IMHO, a consistency is the most important rule here. I do not have any problems with any of those proposals, providing that I can apply similar reasoning to other

RE: drop take [was: fixing typos in Haskell-98]

2000-01-24 Thread BYRNE, Peter
] Subject: Re: drop take [was: fixing typos in Haskell-98] IMHO, that would be the _insane_ definitions :-) Firstly, nothing suggests to me that rationale of such behaviour. The rationale is: 1. these are useful functions 2. if this is insane, so is python. The correspond

Re: fixing typos in Haskell-98

2000-01-24 Thread Fergus Henderson
Simon Peyton-Jones [EMAIL PROTECTED] wrote: (A) Make them defined for any n. If n 0, do something reasonable: take: give empty list drop: give whole list (B) Make them defined for n length xs, but fail for n 0. I vote for (B). 'Qrczak' Kowalczyk [EMAIL

Re: drop take [was: fixing typos in Haskell-98]

2000-01-24 Thread Dr. Mark E. Hall
"S. Alexander Jacobson" wrote: The python behavior is: take n list | length list + n 0 = [] drop n list | length list + n 0 = list I think this is the correct complement (dual?) of: take n list | length list - n 0 = list drop n list | lenght list - n 0