Rewrite fold and reduceOption as sum