TL;DR: Unless you’re careful, using
foldMap to build HashMaps (from unordered-containers)
can take O(n2) time. This
can be avoided by:
Building a Map (from containers)
instead;
Using foldr or foldl with
insert; or
Using foldMap to build an intermediate list
[(k, v)] and then building the HashMap with
fromList.
Shout-out to Luke Worth who found this out while we were chasing down performance problems.
Read more...