changed semantics of accumulator in Haskell implementation