Generalize function application over various types and functions.