If I write an instance of Monoid with a horrible complexity for its operation (<>), will GHC know that
mempty <> x = x
x <> mempty = x
and avoid computing (<>) ?
I'm also interested in how you got that information, and, if this optimization does not exits, whether this could be done or has been discussed previously.
Here's a sketch for how a rewrite rule can accomplish what you've layed out in your comment: