shachaf at gmail.com
Mon Jan 4 01:21:16 UTC 2016
It sounds like Coyoneda -- i.e. Mapped with the "a" existential --
might be what you're looking for:
On Sun, Jan 3, 2016 at 5:11 PM, Henning Thielemann
<lemming at henning-thielemann.de> wrote:
> On Mon, 4 Jan 2016, Oliver Charles wrote:
>> Could you provide some examples where you have found it useful?
> E.g. Set has Foldable instance, but not Functor. Using Mapped I can
> implement argmax in a generic way, such that it also works on Set.
> argmax :: (Ord b, Foldable f) => (a -> b) -> f a -> a
> argmax f = snd . Fold.maximumBy (comparing fst) . Mapped (\a -> (f a, a))
> Libraries mailing list
> Libraries at haskell.org
More information about the Libraries