#| Filter incoming messages according to predicate.
sub filter(&logger, &pred) {
-> $msg { logger($msg) if pred($msg) };
}
#| Transform incoming messages, e.g. censor passwords, add timestamp, etc.
sub transform(&logger, &func) {
-> $msg { logger(func($msg)) };
}
my &logger = &say;
my &timed-logger = transform(&logger, { "{now} {$_}" });
logger("hello world");
timed-logger("hello world");