You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At times I find it's useful to retain the original function when passed to an adverb, such as possibly().
Obviously, when the original function is available by direct reference, this is a non-issue:
orig_f<-function(...) { do_some_stuff };
new_f<-purrr::possibly(f)
so_something_with(orig_f) ## still have access to orig_f
But when using adverbs in a slightly more functional (and less-declarative) manner, I find I like to do something like this:
Thanks for filing this issue! Unfortunately, while I think it's an interesting idea, I think it's out of scope for this package: developing good software requires relentless focus, which means that we have to say no to many good ideas. Even though I'm closing this issue, I really appreciate the feedback, and hope you'll continue to contribute in the future 😄
At times I find it's useful to retain the original function when passed to an adverb, such as
possibly()
.Obviously, when the original function is available by direct reference, this is a non-issue:
But when using adverbs in a slightly more functional (and less-declarative) manner, I find I like to do something like this:
... and when wanting to do something with the original function I do (something along the lines of):
That ^ approach is a bit of a leaky abstraction, so I'm wondering if there's appetite for an accessor like:
get_wrapped_fun(the_only_f)
The only {purrr} adverb where that example API wouldn't really work is
compose()
, though a more generic:get_wrapped_funs(adverbed_f)
... could yield a list of functions.
Just a thought, as whenever I find myself plucking objects out of a function's environment I think to myself, "this is unsafe" :-)
Cheers!
The text was updated successfully, but these errors were encountered: