Accumulate into the intermediate_type in scan's implementation