Many common operations are monoids. Haskell has leveraged this observation to make many higher-order functions more generic (
Foldable being one example).
There is one obvious way in which using monoids can be used to improve performance: the programmers is asserting the operation's associativity, and so operations can be parallelized.
I'm curious if there are any other ways a compiler could optimize the code, knowing that we're dealing with a monoid.