insertWith package:parameterized-utils

insertWith f new m inserts the binding into m. It inserts f new old if m already contains an equivalent value old, and new otherwise. It returns an Unchanged value if the map stays the same size and an Updated value if a new entry was inserted.