[Haskell-cafe] Where do trivial functions on the usual containers live?

Henning Thielemann lemming at henning-thielemann.de
Sun Dec 20 17:53:48 UTC 2020


On Sun, 20 Dec 2020, Ignat Insarov wrote:

>> > * From a finite map, get a map from its range to its fibers:
>> >
>> > fibers ∷ (Ord k, Ord v) ⇒ Map k v → Map v (NonEmpty k)
>>
>> Why NonEmpty, and not Set? Or any Monoid? And more importantly, who are we to
>> decide? Again, the cost difference between maintaining and re-discovering one
>> "standard" vs. re-implementing something more precisely suited to the task at
>> hand via (e.g.) Data.Map.foldMapWithKey doesn't seem worth it.
>
> Because a fiber is non-empty. Ideally, sure, I would like `(k, Set k)`.

NonEmptyMap (and NonEmptySet?) were already discussed here.

I also have:
    https://hackage.haskell.org/package/non-empty-0.3.2/docs/Data-NonEmpty-Set.html


More information about the Haskell-Cafe mailing list