The Haskell 2010 Language Report states in section 20.10.1.1 that:
deleteBy :: (a -> a -> Bool) -> a -> [a] -> [a]
In fact, the implementation in the GHC library would allow
deleteBy :: (b -> a -> Bool) -> b -> [a] -> [a]
but actually restricts the type to the former one with the annotation.
Hence, one cannot say, for instance:
foo = deleteBy fsteq 42 [(43, "foo"), (44, "bar"), (42, "baz")] where
fsteq a (b,_) = a == b
because Int
is not the same as (Int, String)
.
Is there any good reason for this?
The reason I am asking is that, if there is no good reason for it, I would include deleteBy
with the more general type in the Frege port of Data.List I am currently doing. But maybe I am overlooking something?
EDIT: As @hammar pointed out, this applies to other xxxBy functions also.