Apply decorators to a function

Description

%@% reads left to right: in a %@% b %@% f, a is the outermost decorator and f the innermost function. A plain function(f) that returns a function also works as a decorator on the left-hand side.

Usage

lhs %@% rhs

Arguments

lhs A decorator.
rhs A function, or another decorator to compose with.

Value

The decorated function, or a composed decorator if rhs is itself a decorator.

Examples

library("adorn")

loud <- decorator(function(f, ...) toupper(f(...))) %@% function() "hi"
loud()
#> [1] "HI"