With Trine this would be
function process () {
return this
::filter(isOk)
::map(toOtherType)
::flatten();
}
and then later: groupsOfItems::map(process);
Granted, the `flatten` function is not in the Trine yet, somehow forgot that from the initial release.