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

Ignat Insarov kindaro at gmail.com
Sun Dec 20 11:23:36 UTC 2020


Hello.

I am looking for a place where I can find or put some simple functions that I
expect but do not find in the `containers` or elsewhere in the standard
libraries. Some examples I have in mind:

* Group a collection by an equivalence relation:

      classify ∷ Ord π ⇒ (a → π) → [a] → [[a]]

* 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)

* Put a type into the diagonal of its square:

      diagonal = λx → (x, x)

These are all very common and trivial mathematical constructions and I really
want such things to be common place in Haskell, so that they may have a
canonical, polished definition. It is unfeasible to put them into the standard
libraries. _(Attempts were made.)_ So I wonder if there is a package around that
would accept them!


More information about the Haskell-Cafe mailing list