made sum recursively
sum now infers type while evaluating