Foundations for behavioral higher-order contracts