rmonad
rmonad copied to clipboard
Lost history in non-`rmonad` nesting
These all record the same history:
foo <- function(x){ "in foo" ; x %>>% sqrt }
bar <- function(x){ "in bar" ; foo(x)}
256 %>>% sqrt %>>% sqrt %>>% bar
16 %>>% sqrt %>>% bar
4 %>>% bar
This, for example, prevents the use of wrappers around pipeline functions.
foo <- function(x,y){ x %>>% prod(y) }
bar <- function(x){ foo(x, 2) }
# keeps history
16 %>>% sqrt %>>% foo(2)
# loses history
16 %>>% sqrt %>>% bar