Maps with disjoint sets as the key. The type in this module can be
roughly understood as:

DisjointMap k v ≈ Map (Set k) v

Internally, DisjointMap is implemented like a disjoint set
but the data structure that maps representatives to their rank also holds the value
associated with that representative element. Additionally, it holds the set
of all keys that in the same equivalence class as the representative.
This makes it possible to implementat functions like foldlWithKeys'
efficiently.

Insert a key-value pair into the disjoint map. If the key
is is already present in another set, combine the value
monoidally with the value belonging to it.
Otherwise, this creates a singleton set as a new key and
associates it with the value.

Tutorial

The disjoint map data structure can be used to model scenarios where
the key of a map is a disjoint set. Let us consider trying to find
the lowest rating of our by town. Due to differing subcultures,
inhabitants do not necessarily agree on a canonical name for each town.
Consequently, the survey allows participants to write in their town
name as they would call it. We begin with a rating data type: