Proposal: add ordNub somewhere in containers
Henning Thielemann
lemming at henning-thielemann.de
Tue Oct 17 09:32:27 UTC 2017
On Tue, 17 Oct 2017, Eric Torreborre via Libraries wrote:
> As a tangent I am interested in knowing what would be the typeclass for this sort of operation:
>
> - take all the elements out of `f a`
> - do something with them with a function a -> b
> - insert the results back to get the same "original shape" `f b`
I guess, this one can only be Functor.
> In this case "do something with them" is "order them"
A function of type (a -> b) would not be able to order elements.
ordNub could be implemented using Traversable:
catMaybes (traverse ??? xs :: [Maybe a])
You would only need a generalization for catMaybes like mfilter.
More information about the Libraries
mailing list