Type classes provide a clean, modular and elegant way of writing overloaded functions. Functional logic programming languages (FLP in short) like Toy or Curry have adopted the Damas-Milner type system, so it seems natural to adopt also type classes in FLP. However, type classes has been barely introduced in FLP. A reason for this lack of success is that the usual translation of type classes using dictionaries presents some problems in FLP like the absence of expected answers due to a bad interaction of dictionaries withudthe call-time choice semantics for non-determinism adopted in FLP systems.ududIn this paper we present a type-passing translation of typeudclasses based on type-indexed functions and type witnesses that is well-typed with respect to a new liberal type system recently proposed for FLP. We argue the suitability of this translation for FLP because it improves the dictionary-based one in three aspects. First, it obtains programs which run as fast or faster—with an speedup from 1.05 to 2.30 in our experiments. Second, it solves the mentioned problem of missing answers. Finally, the proposed translation generates shorter and simpler programs.ududud(C) ACM, (2011). This is the authors version of the work. It is posted here by permission of ACM for your personal use. Not for redistribution. The definitive version was published in PEPM ’11 Proceedings of the 20th ACM SIGPLAN workshop onudPartial evaluation and program manipulation (January 24–25, 2011, Austin, Texas, USA). http://doi.acm.org/10.1145/1929501.1929524.ud
展开▼
机译:类型类提供了一种干净,模块化且优雅的方式来编写重载函数。诸如Toy或Curry之类的功能逻辑编程语言(简称FLP)已采用Damas-Milner类型系统,因此在FLP中也采用类型类似乎很自然。但是,在FLP中几乎没有引入类型类。缺乏成功的原因是,使用字典进行类型类的常规翻译在FLP中存在一些问题,例如由于字典与 LP在FLP中采用的非确定性的调用时选择语义的不良交互而导致缺少期望的答案 ud ud本文介绍基于类型索引函数和类型见证的类型 udclasss的类型传递转换,该转换相对于最近为FLP提出的新的自由类型系统是类型正确的。我们认为这种翻译对FLP的适用性是因为它在三个方面改进了基于字典的翻译。首先,它获得运行速度更快或更快的程序-在我们的实验中,速度从1.05提高到2.30。其次,它解决了提到的缺少答案的问题。最后,提出的翻译生成了更短,更简单的程序。 ud ud ud(C)ACM,(2011)。这是作品的作者版本。经ACM许可将其张贴在此处供您个人使用。不用于重新分配。最终版本已发布在第20届ACM SIGPLAN关于 ud部分评估和程序操纵的研讨会上的PEPM '11会议记录中(2011年1月24日至25日,美国德克萨斯州奥斯汀)。 http://doi.acm.org/10.1145/1929501.1929524.ud
展开▼
机译:转换术语± Sup> [n i Sub>] f(+/-) min sup>的条件最小化结构的逻辑动态过程的方法Sub> AND ± Sup> [m i Sub>] f(+/-) min Sub>在功能添加结构中± Sup> f < Sub> 1 Sub>(Σ RU Sub>) min Sub>,不带纹波f 1 Sub>(± Sup>←←)和循环ΔtΣ Sub>→5∙f(&)-和5个条件逻辑函数f(&)-,并通过三元数系统的算术公理同时转换术语参数的过程f RU Sub>(+ 1,0,-1)及其实现其的功能结构(俄罗斯逻辑版本)