Type-safe higher-order channels in ML-like languages