Use metaprogramming for function parameters

This work is just for fun as a way to learn R's metaprogramming some more. I am trying to implement list comprehensions like you might see in Haskell or Python. I am just not sure how to fix one tiny part of the process. I am following this example implementation of %>% with some changes. Here's the code:

library(rlang)
`%c|%` <- function(lhs, rhs){
  lhs <- (substitute(lhs))
  rhs <- (substitute(rhs))
  if (rhs[[1L]] == ".") rhs[[1]] = quote(list)
  e <- expr(purrr::pmap(!!rhs, \(x, y) !!lhs))
  eval(e, envir = parent.frame())
}
c(x, y) %c|% .(x = 1:2, y = 10:11)
# returns as expected
[[1]]
[1]  1 10

[[2]]
[1]  2 11

As you might notice, the problem is that I've had to hardcode in \(x, y) myself. I can't figure out how to have that created programmatically similar to the rest of the setup. Another problem with this is I'd like the operator to work even if extraneous variables are provided. E.g.:

> c(x, y) %c|% .(x = 1:2, y = 10:11, z = letters[1:2])
Error in `purrr::pmap()`:
ℹ In index: 1.
Caused by error in `.f()`:
! unused argument (z = .l[[3]][[i]])

I've been going through the Metaprogramming chapters of Advanced R, but can't seem to find the solution. I want to replace the hardcoded \(x, y) with something that will be created based on the named parameters on the right-hand side. So in the above example, I would need to create \(x, y, z) or function(x, y, z).

I've come up with 2 solutions, both inelegant in my opinion, and I am still assuming there is a better solution.

library(rlang)
`%c|%` <- function(lhs, rhs){
  lhs <- (substitute(lhs))
  rhs <- (substitute(rhs))
  
  if (rhs[[1L]] == ".") rhs[[1]] = quote(list)
  args <- (paste(names(as.list(rhs[-1L])), collapse = ","))
  e <- expr(purrr::pmap(!!rhs, \(...) {
    args <- list(...)
    for(i in 1:length(args)) {
      assign(x = names(args)[i], value = args[[i]])
    }
    !!lhs
    }
    ))
  eval(e, envir = parent.frame())
}

Alternative solution with some string manipulation:

`%c|%` <- function(lhs, rhs){
  lhs <- (substitute(lhs))
  rhs <- (substitute(rhs))
  if (rhs[[1L]] == ".") rhs[[1]] = quote(list)
  e <- expr(purrr::pmap(!!rhs, \(args) {!!lhs}))
  e <- gsub("args", paste(names(as.list(rhs[-1L])), collapse = ","), e, fixed = TRUE)
  building_blocks <- lapply(e, str2lang)
  call <- as.call(building_blocks)
  eval(call, envir = parent.frame())
}