Proposal to generalize the type of List's deleteBy function

Andreas Abel abela at chalmers.se
Sun Jun 21 15:30:18 UTC 2015


+1.

On 21.06.2015 08:32, Grant Slatton wrote:
> Right now the type of deleteBy is:
>
> (a -> a -> Bool) -> a -> [a] -> [a]
>
> That is, it takes an equality predicate, a value, and a list, and
> deletes the first element in the list such that the equality predicate
> returns true for the given value and the element.
>
> This can be generalized to:
>
> (a -> b -> Bool) -> a -> [b] -> [b]
>
>
> Example use case:
>
> keyValues :: [(a, b)]
>
> key :: a
>
> deleteBy (\x (y, _) -> x == y) key keyValues
>
>
>
> Thanks
>
> Grant Slatton
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>


-- 
Andreas Abel  <><      Du bist der geliebte Mensch.

Department of Computer Science and Engineering
Chalmers and Gothenburg University, Sweden

andreas.abel at gu.se
http://www2.tcs.ifi.lmu.de/~abel/


More information about the Libraries mailing list