Let $\mathbf{C}$ be a Cartesian closed category. Then simply typed lambda calculus in $\mathbf{C}$ in one type variable can be interpreted as a category $\mathbf{STLC}_{\mathbf C}$ where the objects are functors from $\mathbf{C}^\text{op} \times \mathbf{C}$ to $\mathbf{C}$ and the morphisms are dinatural transformations between the functors, see for example “Normal Forms and Cut-Free Proofs as Natural Transformations” by Girard, Scedrov, and Scott. I am looking at lambda polymorphism in this category. Say we have the Church numeral $n$ with signature $\Pi x . (x \rightarrow x) \rightarrow x \rightarrow x$ and want to apply this to a second Church numeral $m$ with signature $\Pi y . (y \rightarrow y) \rightarrow y \rightarrow y$.
$$n\ m$$
In simply typed lambda calculus, this is not allowed, because $m$ does not have a type that $n$ accepts as input. In order to evaluate this expression, we have to “lift” $n$ by $(y \rightarrow y)$ to a new variable $n'$ with the signature
$$(\Pi x . (x \rightarrow x) \rightarrow x \rightarrow x)) (y \rightarrow y) = ((y \rightarrow y) \rightarrow (y \rightarrow y)) \rightarrow (y \rightarrow y) \rightarrow (y \rightarrow y)$$
so that every $x$ in the signature is replaced with $(y \rightarrow y)$. Then, $n'\ m$ has correct types for the application.
This “lifting” seems to me like a monoid in $\mathbf{STLC}_{\mathbf C}$ with identity $\Pi x . x$, the identity functor. Is that correct?
Also, one could call the lambda calculus terms a special type of endofunctors, of mixed variance, that are the objects of a category where the arrows are dinatural transformations that do compose, as proved in the paper mentioned above. A monoid in this endofunctor-category-like thing looks very much like a generalization of a monad in $\mathbf{C}$ . Does this concept have a name?