Union and intersection types are a staple of gradually typed language such as TypeScript. While it's long been recognized that union and intersection types are difficult to verify statically, it may appear at first that the dynamic part of gradual typing is actually pretty simple. It turns out however, that in presence of higher-order contracts union and intersection are deceptively difficult. The literature on higher-order contracts with union and intersection, while keenly aware of the fact, doesn't really explain why. We point and illustrate the problems and trade-offs inherent to union and intersection contracts, via example and a survey of the literature.
翻译:联合和交叉类型是诸如 TypeScript 等逐步打字语言的主菜。 虽然长期以来人们都认识到,联合和交叉类型很难静态地核实,但起初似乎逐渐打字的动态部分其实相当简单。 但是,事实证明,在较高订单合同存在的情况下,工会和交叉是难以理解的。 关于与工会和交叉连接的较高订单合同的文献虽然非常清楚这一事实,但并不能真正解释原因。我们通过实例和文献调查,指出并说明了工会和交叉合同所固有的问题和权衡。