Generalise type of deleteBy

Edward Kmett ekmett at gmail.com
Sun Sep 11 19:15:27 UTC 2016


I have to admit I've always found the need to pass an argument to deleteBy
sort of silly. The few times I've used it, my function has just ignored the
first argument. I don't think we need to worry too much about inference in
this case, the user would almost assuredly pick it back up on the backswing
from whatever (a -> a -> Bool) predicate they are using fixing the type
anyways.

I don't find the two proposals mutually exclusive.

-Edward

On Sun, Sep 11, 2016 at 1:00 PM, Eric Mertens <emertens at gmail.com> wrote:

> Going with Henning's newDeleteBy would provide a better interface to
> deleting with an arbitrary predicate, and it would avoid the (unlikely?)
> chance of code breaking in the event that the more general type breaks some
> type inference.
>
> On Sun, Sep 11, 2016, 9:19 AM Henning Thielemann <
> lemming at henning-thielemann.de> wrote:
>
>>
>> On Sun, 11 Sep 2016, Matthew Pickering wrote:
>>
>> > The type of `deleteBy` in `Data.List` could easily be generalised in a
>> > useful way.
>> >
>> > ```
>> > deleteBy :: (a -> a -> Bool) -> a -> [a] -> [a]
>> > ```
>>
>> I do not see why deleteBy should have an argument for the deleted element,
>> anyway, since it is not even the element to delete (only an equivalent
>> one). Wouldn't a function with type
>>
>> newDeleteBy :: (a -> Bool) -> [a] -> [a]
>>
>> be much more straight-forward?
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20160911/79f34d8c/attachment.html>


More information about the Libraries mailing list