Applies decorators to f left-to-right so that
decorate(f, d1, d2) is equivalent to d2(d1(f)) and reads outside-in.
Each decorator must be a unary function function(g) -> function.
For decorators with configuration, wrap them in a closure or use the
native pipe directly (which is the recommended idiom).
Examples
# \donttest{
add1 <- function(x) x + 1
g <- decorate(
add1,
function(fn) with_retry(fn, max_tries = 2, backoff = 0),
function(fn) with_timing(fn, .threshold = Inf)
)
g(41)
#> [1] 42
# }