[Haskell-cafe] whine and solution about programmers not respecting
trebla at vex.net
Mon Jun 28 15:44:34 EDT 2010
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 on #haskell expected it to accomplish something meaningful,
even something mind-reading. The said person has been around for more than
a year, not eligible for the "newbie" excuse. The said person is just the
tip of an iceberg.
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 isn't analogous to (==)" or the
mathematical sense of "it isn't an equivalence relation".
If you respect the precondition or the authors of the doc, you should just
never use deleteBy (>=) 5 [0..10], much less expect any meaningful result.
I propose this solution:
For each of deleteBy, groupBy, unionBy... we can usually conceive at least two
implementations, behaving pretty much the same (answer, speed, space) when
given an equivalence relation (modulo some rare concern when the equivalence
relation has assymetric strictness properties), but behaving different when
not, and their code sizes are pretty much the same. With more imagination and
allowing some code bloat, perhaps we can conceieve more implementations. But
two suffices, really.
I propose that at each minor version of base, someone picks an implementation
Here is a more radical, less labour-intensive solution, if you don't mind a
judicious, correctness-preserving use of unsafePerformIO: at the first
invocation of the process lifetime, pick an implementation randomly.
The result frustrates people who disrespect the docs. My purpose is exactly
that. The goal is to give people an incentive to not disrepect the docs.
(If you think this is a nasty "stick, not carrot" incentive, on first thought I
would agree. On second thought, it is not adding a stick, it is just removing a
carrot. Programmer's carrot means his/her code "works" consistently. When
deleteBy (>=) "works" consistently, you are giving out undeserved free carrots
--- incentive to write more wrong code. I am proposing to remove undeserved
More information about the Haskell-Cafe