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

Roman Beslik beroal at ukr.net
Tue Jun 29 18:51:39 EDT 2010

  On 29.06.10 08:37, Ketil Malde wrote:
> Albert Y.C.Lai<trebla at vex.net>  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 isn't analogous to (==)" or the
>> mathematical sense of "it isn't an equivalence relation".
> One could argue that this is a bad specification.  The type is
>    deleteBy :: (a ->  a ->  Bool) ->  a ->  [a] ->  [a]
> but there are further limitations on the arguments, and worse, the function
> doesn't check this and produce an error if the arguments don't conform,
> but just silently produces a meaningless result.
How can 'deleteBy' check that an argument is an equivalence relation? 
(Putting aside that this harms performance.)

Best regards,
   Roman Beslik.

More information about the Haskell-Cafe mailing list