Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-29 Thread Roman Beslik
On 29.06.10 08:37, Ketil Malde wrote: Albert Y.C.Lai writes: The doc of deleteBy states: "The deleteBy function behaves like delete, but takes a user-supplied equality predicate." A precondition is that the user-supplied predicate is an equality predicate. (>=) is not an equality predicate, be

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-29 Thread Ivan Lazar Miljenovic
Daniel Fischer writes: > On Tuesday 29 June 2010 13:02:20, Ivan Lazar Miljenovic wrote: >> >> That's like asking why we have mapM and forM, etc. > > Yes, why? > > (okay, I use forM too, it's so much more readable with a short list and a > long action) Exactly; using "deleteBy p" (if it was fixe

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-29 Thread Daniel Fischer
On Tuesday 29 June 2010 13:02:20, Ivan Lazar Miljenovic wrote: > > That's like asking why we have mapM and forM, etc. Yes, why? (okay, I use forM too, it's so much more readable with a short list and a long action) ___ Haskell-Cafe mailing list Haskell

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-29 Thread Daniel Fischer
On Tuesday 29 June 2010 12:50:34, Ketil Malde wrote: > Daniel Fischer writes: > >> An important point of a powerful type system is to model your program > >> so that only sensible code is legal. > > > > That would be an awesomely powerful type system :) > > Heh. But while we're waiting for it, we

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-29 Thread Ivan Lazar Miljenovic
Daniel Fischer writes: > That's more common, yes (I don't remember ever having used delete(By) > intentionally). But we've filter for that, so it wouldn't make sense to > give delete(By) the same semantics. Hence, if you provide both names, what > else could deleteBy do? That's like asking wh

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-29 Thread Daniel Fischer
On Tuesday 29 June 2010 12:46:21, Ivan Lazar Miljenovic wrote: > > At most one element, yes; I question why that design decision was made > as I'm more likely to want to delete all values rather than just the > first one That's more common, yes (I don't remember ever having used delete(By) intent

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-29 Thread Ketil Malde
Daniel Fischer writes: >> An important point of a powerful type system is to model your program so >> that only sensible code is legal. > That would be an awesomely powerful type system :) Heh. But while we're waiting for it, we can try to use what we got to eliminate as much non-sensical code

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-29 Thread Ivan Lazar Miljenovic
Ketil Malde writes: > Max Rabkin writes: > >> Your deleteBy is (filter . not), isn't it? > > With the caveat that I haven't actually used it, my impression is that > delete only removes one element, while filter removes all of them. At most one element, yes; I question why that design decision

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-29 Thread Ketil Malde
Max Rabkin writes: > Your deleteBy is (filter . not), isn't it? With the caveat that I haven't actually used it, my impression is that delete only removes one element, while filter removes all of them. -k -- If I haven't seen further, it is by standing in the footprints of giants _

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-29 Thread Ivan Lazar Miljenovic
Max Rabkin writes: > On Tue, Jun 29, 2010 at 11:46 AM, Ketil Malde wrote: >>  deleteBy :: (a -> Bool) -> [a] -> [a] >> >> I don't think there would be any doubt what 'deleteBy (<= 5) [1..10]' >> would do. And I just don't see what the requirement for an equivalence >> relation buys you. > > Your

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-29 Thread Daniel Fischer
On Tuesday 29 June 2010 11:46:47, Ketil Malde wrote: > > An important point of a powerful type system is to model your program so > that only sensible code is legal. That would be an awesomely powerful type system :) > This makes me wonder why deleteBy is > defined so loosely, instead of e.g. > >

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-29 Thread Max Rabkin
On Tue, Jun 29, 2010 at 11:46 AM, Ketil Malde wrote: >  deleteBy :: (a -> Bool) -> [a] -> [a] > > I don't think there would be any doubt what 'deleteBy (<= 5) [1..10]' > would do. And I just don't see what the requirement for an equivalence > relation buys you. Your deleteBy is (filter . not), is

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-29 Thread Ketil Malde
Daniel Fischer writes: >> Maybe it is because deleteBy is defined wrongly? i.e. it is not logical, >> doesn't follow the common sense user might expect. It accepts any >> predicate but narrows requirements only in docs. > Unfortunately, you can't easily encode the requirement that it ought to be

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-29 Thread Daniel Fischer
On Tuesday 29 June 2010 10:47:40, Zura_ wrote: > Maybe it is because deleteBy is defined wrongly? i.e. it is not logical, > doesn't follow the common sense user might expect. It accepts any > predicate but narrows requirements only in docs. Unfortunately, you can't easily encode the requirement th

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-29 Thread Zura_
Maybe it is because deleteBy is defined wrongly? i.e. it is not logical, doesn't follow the common sense user might expect. It accepts any predicate but narrows requirements only in docs. Maybe best could be to just take a value for comparison and use "==" against it? ("overloaded" or "built-in"

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-28 Thread Lars Viklund
On Mon, Jun 28, 2010 at 07:44:34PM +, Albert Y.C.Lai wrote: > I propose that at each minor version of base, someone picks an implementation > randomly. > > Here is a more radical, less labour-intensive solution, if you don't mind a > judicious, correctness-preserving use of unsafePerformIO: at

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-28 Thread Edward Z. Yang
Excerpts from Albert Y.C.Lai's message of Mon Jun 28 15:44:34 -0400 2010: > I propose that at each minor version of base, someone picks an implementation > randomly. This has actually been done, in a legitimate language implementation. Check out: http://web.mit.edu/~axch/www/scheme/choices/non-as

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-28 Thread Ketil Malde
Albert Y.C.Lai writes: > The doc of deleteBy states: "The deleteBy function behaves like delete, but > takes a user-supplied equality predicate." A precondition is that the > user-supplied predicate is an equality predicate. (>=) is not an equality > predicate, be it in the layperson sense of "it

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-28 Thread Mark Lentczner
On Jun 28, 2010, at 2:29 PM, Luke Palmer wrote: > I proposed the following solution: > > http://lukepalmer.wordpress.com/2009/07/01/on-the-by-functions/ Seconded! I always want xxxOn and I almost never (perhaps never*) want xxxBy for xxx in sort, maximum, group and nub. - Mark (*) A

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-28 Thread Roman Beslik
In the case of 'deleteBy' we can improve an API. deleteBy eq x xs == deletePred (eq x) xs @deletePred pred xs@ removes the first element of @xs@ which satisfies a predicate @p...@. Your solution is more general. :) On 28.06.10 22:44, Albert Y.C.Lai wrote: And then some programmers are in a

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-28 Thread Luke Palmer
On Mon, Jun 28, 2010 at 1:44 PM, Albert Y.C.Lai wrote: > Why should anyone expect > >  deleteBy (>=) 5 [0..10] > > to accomplish anything meaningful, if he/she respects the written docs? I proposed the following solution: http://lukepalmer.wordpress.com/2009/07/01/on-the-by-functions/ > > Tod

[Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-28 Thread Albert Y . C . Lai
Some docs are in a miserable state of being incomplete. And then some programmers are in a miserable state of not respecting docs when the docs are complete. Why should anyone expect deleteBy (>=) 5 [0..10] to accomplish anything meaningful, if he/she respects the written docs? Today someone