Data types and codata types are, as the names suggest, often seen as duals of each other. However, most programming languages do not support both of them in their full generality, or if they do, they are still seen as distinct constructs with separately defined type-checking, compilation, etc. Rendel et al. were the first to propose variants of two standard program transformations, de- and refunctionalization, as a test to gauge and improve the symmetry between data and codata types. However, in previous works, codata and data were still seen as separately defined language constructs, with de- and refunctionalization being defined as similar but separate algorithms. These works also glossed over interactions between the aforementioned transformations and evaluation order, which leads to a loss of desirable $\eta$ expansion equalities. We argue that the failure of complete symmetry is due to the inherent asymmetry of natural deduction as the logical foundation of the language design. Natural deduction is asymmetric in that its focus is on producers (proofs) of types, whereas consumers (contexts, continuations, refutations) have a second-class status. Inspired by existing sequent-calculus-based language designs, we present the first language design that is fully symmetric in that the issues of polarity (data type vs codata types) and evaluation order (call-by-value vs call-by-name) are untangled and become independent attributes of a single form of type declaration. Both attributes, polarity and evaluation order, can be changed independently by one algorithm each. In particular, defunctionalization and refunctionalization are now one algorithm. Evaluation order can be defined and changed individually for each type, independently from polarity. By allowing only certain combinations of evaluation order and polarity, the aforementioned $\eta$ laws can be restored.
翻译:正如这些名称所示,数据类型和共数据类型通常被视为是双向的。然而,大多数编程语言在完全的通用性中并不支持它们,或者如果支持它们,它们仍然被视为不同结构,分别定义了类型检查、汇编等。Rendel et al.是第一个提出两种标准程序变换的变体,即去和重新配置的变体,作为衡量和改进数据和共数据类型之间对称性的测试。但在以前的作品中,共和数据仍然被视为单独界定的语言结构,其去和再功能化的定义是相似的,但不同的算法类型是不同的。上述变换和评审顺序之间的相互作用被忽略了。Rendel 等人认为,完全的对称之所以不能完全对称,是因为作为语言设计逻辑基础的自然减法的内在不对称。自然减法的内在偏重度,因为其重心是各类的制成者(校对),而消费者(文字、连续、重新配置)的反向值是独立的。我们现有的单种语言变数的变数结构是完全的调整状态。通过现有的单级的变数顺序变的变变的顺序,我们的顺序的变的对的顺序的变的顺序是正的顺序是正的顺序的。通过现有的的顺序的顺序的顺序的顺序的正正正的顺序,我们的顺序的顺序的顺序是完全的正的变变的变的变的。