Text this: RPO, Second-order Contexts, and Lambda-calculus