Infer the intermediate_type in scan algorithms.