Balanced Reduce implementation for Haskell