Use weigh
It was recently observed that foundation is faster than text/bytestring even though it allocates a lot more: https://github.com/ndmitchell/weeder/pull/27
I suspect if you allocated less you'd we way faster. You might want to use https://hackage.haskell.org/package/weigh to benchmark your allocations, as that would then let you measure and confirm progress, and prevent regressions
Given this project, I suspect this will cause you to reinvent the package first...
heh, I like weigh (and I have used it in the past) ;p
Also while it's globally true that less allocation is better, it doesn't necessary translate all the time in less cpu time. Of course thought, I'm pretty sure we can do better on the two different metrics...
Yep, I think reducing allocation for allocations sake is pointless - but I find it almost always does translate to less CPU time if you keep everything else constant (fewer GC runs at minimum).