Why are difference lists more efficient than regular concatenation in Haskell?
The problem in ((((a ++ b) ++ c) ++ d) ++ e) ++ f is the nesting. The applications of (++) are left-nested, and that’s bad; right-nesting a ++ (b ++ (c ++ (d ++ (e ++f)))) would not be a problem. That is because (++) is defined as [] ++ ys = ys (x:xs) … Read more