
17 Oct
2017
17 Oct
'17
5:32 a.m.
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.