Fixes for fold.

Clang can't figure out the template argument for the accumulator automatically, so we will need to add this to code generation if possible.

Also, group by is still incorrect. Still need to convert to a proper curried function. Also, it should not return a tuple, but instead a record. (How?)