Exposing higher-order function

It’s super messy - for new functions, I’d advise just following the scheme that the std::ostream* msgs argument always comes last, or switching to it always coming first if we want to make use of C++ default arguments rather than just using telescoping overloads.

The messy code to deal with the existing placements that break this rule is here: https://github.com/stan-dev/stanc3/blob/master/src/stan_math_backend/Expression_gen.ml#L281