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

Ketil Malde ketil at malde.org
Tue Jun 29 05:46:47 EDT 2010


Daniel Fischer <daniel.is.fischer at web.de> 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 
> an equivalence relation via types. 

This is just another way of saying the same thing :-)

An important point of a powerful type system is to model your program so
that only sensible code is legal.  This makes me wonder why deleteBy is
defined so loosely, instead of e.g.

  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.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants


More information about the Haskell-Cafe mailing list