tweag / HaskellR

The full power of R in Haskell.
https://tweag.github.io/HaskellR
Other
584 stars 47 forks source link

Mutable vectors passed to R as mutable #416

Open djsamperi opened 1 year ago

djsamperi commented 1 year ago

Is your feature request related to a problem? Please describe. One might expect that when a mutable vector is passed to a quasiquote, that the R code in the quasiquote can modify the vector. But this is not the case. The vector is passed by value.

Describe the solution you'd like Since these mutable vectors on the Haskell side are actually proxies for R vectors, R should be able to work with them just like it works with native R vectors.

Describe alternatives you've considered Of course, we could simply copy out the vector as a list using fromList, but the point is to reduce the amount of copying.

Additional context This would probably require some redesign of the Haskell/R interface because the current interface evaluates the R expresion in a quasiquote by placing it into an R function parametrized by the input Haskell variables/vectors, and vector parameters are passed by value in R (so the called function cannot change the input vector, mutable or not).

djsamperi commented 1 year ago

After reading the online docs it seems this would violate the working assumption that hexp can be assumed to be pure. I would close this issue of I could, but it seems this is not possible.