fn combine_unrolled_values(bk: BuilderKind, values: Vec<Expr>) -> WeldResult<Expr> {
    if values.is_empty() {
        return compile_err!("Need at least one value to combine in unroller");
    }
    match bk {
        Merger(ref ty, ref binop) => {
            if values.iter().any(|ref expr| expr.ty != *ty.as_ref()) {
                return compile_err!("Mismatched types in Merger and unrolled values.");
            }
            // Use the specified binary op to produce the final expression.
            let mut prev = None;
            for value in values.into_iter() {
                if prev.is_none() {
                    prev = Some(value);
                } else {
                    prev = Some(Expr::new_bin_op(*binop, prev.unwrap(), value)?);
                }
            }
            Ok(prev.unwrap())
        }
        Appender(ref ty) => {
            if values.iter().any(|ref expr| expr.ty != *ty.as_ref()) {
                return compile_err!("Mismatched types in Appender and unrolled values.");
            }
            Expr::new_make_vector(values)
        }
        ref bk => compile_err!(
            "Unroller transform does not support loops with builder of kind {:?}",
            bk
        ),
    }
}
Combines the expressions in `values` into a single value based on the kind of builder the
values would have been merged into.

As an example, if `values` is [ Literal(1), Literal(2), Literal(3)] and the builder was a
merger[i32,+], this function will produce the expression Literal(1) + Literal(2) + Literal(3).
weld/src/optimizer/transforms/unroller.rs