首页 > 最新文献

ACM SIGPLAN Symposium/Workshop on Haskell最新文献

英文 中文
A type-preserving closure conversion in haskell haskell中保持类型的闭包转换
Pub Date : 2007-09-30 DOI: 10.1145/1291201.1291212
Louis-Julien Guillemette, Stefan Monnier
The use of typed intermediate languages can significantly increase the reliability of a compiler. By type-checking the code produced at each transformation stage, one can identify bugs in the compiler that would otherwise be much harder to find. Also it guarantees that any property that was enforced by the source-level type-system is holds also or the generated code. Recently, several people have tried to push this effort a bit further by verifying formally that the compiler indeed preserves typing. This is usually done with proof assistants or experimental languages. Instead, we decided to use Haskell (with GHC's extensions), to see how far we can go with a more mainstream system, supported by robust compilers and plentiful libraries. This article presents one part of our type preserving compiler, namely the closure conversion and its associated hoisting phase, where we use GADTs to let Haskell's type checker verify the we obey the object language's typing rules and that we correctly preserve types from one phase to the other. This should be both a good showcase as well as a good stress test for GADTs, so we also discuss our experience, as well as some trade-offs in the choice of representation, namely between higher-order abstract syntax (HOAS) and a first order representation (i.e. de Bruijn indices) and justify our choice of a de Bruijn representation. We incidentally present a type preserving conversion from HOAS (used in earlier phases of the compiler[6]) to a de Bruijn representation.
类型化中间语言的使用可以显著提高编译器的可靠性。通过对每个转换阶段生成的代码进行类型检查,可以识别编译器中的错误,否则很难发现这些错误。此外,它还保证由源级类型系统强制执行的任何属性也保留在生成的代码中。最近,有几个人试图通过正式验证编译器确实保留了类型来进一步推动这一努力。这通常是通过证明助手或实验语言完成的。相反,我们决定使用Haskell(带有GHC的扩展),看看我们能在一个更主流的系统上走多远,这个系统有强大的编译器和丰富的库支持。本文介绍了类型保留编译器的一部分,即闭包转换及其相关的提升阶段,在这个阶段中,我们使用gadt让Haskell的类型检查器验证我们是否遵守了对象语言的类型规则,并且从一个阶段到另一个阶段都正确地保留了类型。对于gadt来说,这应该既是一个很好的展示,也是一个很好的压力测试,因此我们还讨论了我们的经验,以及在选择表示时的一些权衡,即在高阶抽象语法(HOAS)和一阶表示(即de Bruijn索引)之间进行权衡,并证明我们选择de Bruijn表示是合理的。我们顺便介绍了从HOAS(在编译器的早期阶段使用[6])到de Bruijn表示的类型保留转换。
{"title":"A type-preserving closure conversion in haskell","authors":"Louis-Julien Guillemette, Stefan Monnier","doi":"10.1145/1291201.1291212","DOIUrl":"https://doi.org/10.1145/1291201.1291212","url":null,"abstract":"The use of typed intermediate languages can significantly increase the reliability of a compiler. By type-checking the code produced at each transformation stage, one can identify bugs in the compiler that would otherwise be much harder to find. Also it guarantees that any property that was enforced by the source-level type-system is holds also or the generated code. Recently, several people have tried to push this effort a bit further by verifying formally that the compiler indeed preserves typing. This is usually done with proof assistants or experimental languages.\u0000 Instead, we decided to use Haskell (with GHC's extensions), to see how far we can go with a more mainstream system, supported by robust compilers and plentiful libraries. This article presents one part of our type preserving compiler, namely the closure conversion and its associated hoisting phase, where we use GADTs to let Haskell's type checker verify the we obey the object language's typing rules and that we correctly preserve types from one phase to the other.\u0000 This should be both a good showcase as well as a good stress test for GADTs, so we also discuss our experience, as well as some trade-offs in the choice of representation, namely between higher-order abstract syntax (HOAS) and a first order representation (i.e. de Bruijn indices) and justify our choice of a de Bruijn representation. We incidentally present a type preserving conversion from HOAS (used in earlier phases of the compiler[6]) to a de Bruijn representation.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"2002 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2007-09-30","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"125763374","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
引用次数: 16
Lightweight concurrency primitives for GHC 用于GHC的轻量级并发原语
Pub Date : 2007-09-30 DOI: 10.1145/1291201.1291217
Peng Li, S. Marlow, S. Jones, A. Tolmach
The Glasgow Haskell Compiler (GHC) has quite sophisticated support for concurrency in its runtime system, which is written in low-level C code. As GHC evolves, the runtime system becomes increasingly complex, error-prone, difficult to maintain and difficult to add new concurrency features. This paper presents an alternative approach to implement concurrency in GHC. Rather than hard-wiring all kinds of concurrency features, the runtime system is a thin substrate providing only a small set of concurrency primitives, and the remaining concurrency features are implemented in software libraries written in Haskell. This design improves the safety of concurrency support; it also provides more customizability of concurrency features, which can be developed as Haskell library packages and deployed modularly.
格拉斯哥Haskell编译器(GHC)在运行时系统中对并发性有相当复杂的支持,它是用低级C代码编写的。随着GHC的发展,运行时系统变得越来越复杂、容易出错、难以维护和难以添加新的并发特性。本文提出了在GHC中实现并发的另一种方法。运行时系统不是硬连接各种并发特性,而是一个薄的底层,只提供一小组并发原语,其余的并发特性在用Haskell编写的软件库中实现。这种设计提高了并发支持的安全性;它还提供了更多的并发特性的可定制性,这些特性可以作为Haskell库包开发并模块化部署。
{"title":"Lightweight concurrency primitives for GHC","authors":"Peng Li, S. Marlow, S. Jones, A. Tolmach","doi":"10.1145/1291201.1291217","DOIUrl":"https://doi.org/10.1145/1291201.1291217","url":null,"abstract":"The Glasgow Haskell Compiler (GHC) has quite sophisticated support for concurrency in its runtime system, which is written in low-level C code. As GHC evolves, the runtime system becomes increasingly complex, error-prone, difficult to maintain and difficult to add new concurrency features.\u0000 This paper presents an alternative approach to implement concurrency in GHC. Rather than hard-wiring all kinds of concurrency features, the runtime system is a thin substrate providing only a small set of concurrency primitives, and the remaining concurrency features are implemented in software libraries written in Haskell. This design improves the safety of concurrency support; it also provides more customizability of concurrency features, which can be developed as Haskell library packages and deployed modularly.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"02 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2007-09-30","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"129895192","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
引用次数: 35
A lightweight interactive debugger for haskell 一个用于haskell的轻量级交互调试器
Pub Date : 2007-09-30 DOI: 10.1145/1291201.1291204
S. Marlow, José Iborra, B. Pope, Andy Gill
This paper describes the design and construction of a Haskell source-level debugger built into the GHCi interactive environment. We have taken a pragmatic approach: the debugger is based on the traditional stop-examine-continue model of online debugging, which is simple and intuitive, but has traditionally been shunned in the context of Haskell because it exposes the lazy evaluation order. We argue that this drawback is not as severe as it may seem, and in some cases is an advantage. The design focuses on availability: our debugger is intended to work on all programs that can be compiled with GHC, and without requiring the programmer to jump through additional hoops to debug their program. The debugger has a novel approach for reconstructing the type of runtime values in a polymorphic context. Our implementation is light on complexity, and was integrated into GHC without significant upheaval.
本文描述了一个内置在GHCi交互环境中的Haskell源代码级调试器的设计和构造。我们采用了一种实用的方法:调试器基于传统的在线调试的停止-检查-继续模型,这种模型简单直观,但在Haskell环境中一直被避免使用,因为它暴露了惰性求值顺序。我们认为这个缺点并不像看起来那么严重,在某些情况下是一种优势。设计的重点是可用性:我们的调试器旨在工作在所有可以用GHC编译的程序上,而不需要程序员跳过额外的环节来调试他们的程序。调试器有一种新的方法来重建多态上下文中运行时值的类型。我们的实现在复杂性上很轻,并且在没有显著变化的情况下集成到GHC中。
{"title":"A lightweight interactive debugger for haskell","authors":"S. Marlow, José Iborra, B. Pope, Andy Gill","doi":"10.1145/1291201.1291204","DOIUrl":"https://doi.org/10.1145/1291201.1291204","url":null,"abstract":"This paper describes the design and construction of a Haskell source-level debugger built into the GHCi interactive environment. We have taken a pragmatic approach: the debugger is based on the traditional stop-examine-continue model of online debugging, which is simple and intuitive, but has traditionally been shunned in the context of Haskell because it exposes the lazy evaluation order. We argue that this drawback is not as severe as it may seem, and in some cases is an advantage.\u0000 The design focuses on availability: our debugger is intended to work on all programs that can be compiled with GHC, and without requiring the programmer to jump through additional hoops to debug their program. The debugger has a novel approach for reconstructing the type of runtime values in a polymorphic context. Our implementation is light on complexity, and was integrated into GHC without significant upheaval.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"43 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2007-09-30","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"125113372","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
引用次数: 29
Uniform boilerplate and list processing 统一的样板和列表处理
Pub Date : 2007-09-30 DOI: 10.1145/1291201.1291208
Neil Mitchell, C. Runciman
Generic traversals over recursive data structures are often referred to as boilerplate code. The definitions of functions involving such traversals may repeat very similar patterns, but with variations for different data types and different functionality. Libraries of operations abstracting away boilerplate code typically rely on elaborate types to make operations generic. The motivating observation for this paper is that most traversals have value-specific behaviour for just one type. We present the design of a new library exploiting this assumption. Our library allows concise expression of traversals with competitive performance.
递归数据结构上的泛型遍历通常被称为样板代码。涉及这种遍历的函数定义可能会重复非常相似的模式,但对于不同的数据类型和不同的功能会有所不同。抽象样板代码的操作库通常依赖于复杂的类型来使操作泛型。本文的激励观察结果是,大多数遍历仅针对一种类型具有特定于值的行为。我们利用这一假设提出了一个新图书馆的设计。我们的库允许对具有竞争性性能的遍历进行简洁的表达。
{"title":"Uniform boilerplate and list processing","authors":"Neil Mitchell, C. Runciman","doi":"10.1145/1291201.1291208","DOIUrl":"https://doi.org/10.1145/1291201.1291208","url":null,"abstract":"Generic traversals over recursive data structures are often referred to as boilerplate code. The definitions of functions involving such traversals may repeat very similar patterns, but with variations for different data types and different functionality. Libraries of operations abstracting away boilerplate code typically rely on elaborate types to make operations generic. The motivating observation for this paper is that most traversals have value-specific behaviour for just one type. We present the design of a new library exploiting this assumption. Our library allows concise expression of traversals with competitive performance.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":" 26","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2007-09-30","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"113952116","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
引用次数: 69
A functional-logic library for wired 一个用于有线的功能逻辑库
Pub Date : 2007-09-30 DOI: 10.1145/1291201.1291207
Matthew Naylor, E. Axelsson, C. Runciman
We develop a Haskell library for functional-logic programming, motivated by the implementation of Wired, a relational embedded domain-specific language for describing and analysing digital circuits at the VLSI-layout level. Compared to a previous library for logic programming by Claessen and Ljunglöf, we support residuation, easier creation of logical data types, and pattern matching. We discuss other applications of our library, including test-data generation, and various extensions, including lazy narrowing.
我们开发了一个用于功能逻辑编程的Haskell库,其动机是Wired的实现,Wired是一种用于描述和分析vlsi布局级数字电路的关系嵌入式领域特定语言。与Claessen和Ljunglöf之前的逻辑编程库相比,我们支持保留、更容易创建逻辑数据类型和模式匹配。我们讨论了库的其他应用程序,包括测试数据生成和各种扩展,包括延迟缩小。
{"title":"A functional-logic library for wired","authors":"Matthew Naylor, E. Axelsson, C. Runciman","doi":"10.1145/1291201.1291207","DOIUrl":"https://doi.org/10.1145/1291201.1291207","url":null,"abstract":"We develop a Haskell library for functional-logic programming, motivated by the implementation of Wired, a relational embedded domain-specific language for describing and analysing digital circuits at the VLSI-layout level. Compared to a previous library for logic programming by Claessen and Ljunglöf, we support residuation, easier creation of logical data types, and pattern matching. We discuss other applications of our library, including test-data generation, and various extensions, including lazy narrowing.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"2 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2007-09-30","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"114339337","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
引用次数: 12
Demo outline: switched-on yampa 演示大纲:打开yampa
Pub Date : 2007-09-30 DOI: 10.1145/1291201.1291213
George Giorgidze, H. Nilsson
In this demonstration, we present an implementation of a modular synthesizer in Haskell using Yampa. A synthesizer, be it a hardware instrument or a pure software implementation, as here, is said to be modular if it provides sound-generating and sound-shaping components that can be interconnected in arbitrary ways. Yampa, a Haskell-embedded implementation of Functional Reactive Programming, supports flexible construction of hybrid systems. Since music is a hybrid continuous-time and discrete-time phenomenon, Yampa and is a good fit for such applications, offering some unique possibilities compared to most languages targeting music or audio applications. The demonstration illustrates this point by showing how simple audio blocks can be described and then interconnected in a network with dynamically changing structure, reflecting the changing demands of a musical performance.
在这个演示中,我们展示了一个使用Yampa在Haskell中实现的模块化合成器。合成器,无论是硬件仪器还是纯软件实现,如果它提供了可以任意方式连接的声音产生和声音塑造组件,则被称为模块化。Yampa是一种嵌入haskell的函数式响应式编程实现,支持灵活地构建混合系统。由于音乐是连续时间和离散时间的混合现象,因此Yampa和非常适合此类应用程序,与大多数针对音乐或音频应用程序的语言相比,它提供了一些独特的可能性。演示通过展示如何描述简单的音频块,然后在动态变化的结构网络中相互连接来说明这一点,反映了音乐表演需求的变化。
{"title":"Demo outline: switched-on yampa","authors":"George Giorgidze, H. Nilsson","doi":"10.1145/1291201.1291213","DOIUrl":"https://doi.org/10.1145/1291201.1291213","url":null,"abstract":"In this demonstration, we present an implementation of a modular synthesizer in Haskell using Yampa. A synthesizer, be it a hardware instrument or a pure software implementation, as here, is said to be modular if it provides sound-generating and sound-shaping components that can be interconnected in arbitrary ways. Yampa, a Haskell-embedded implementation of Functional Reactive Programming, supports flexible construction of hybrid systems. Since music is a hybrid continuous-time and discrete-time phenomenon, Yampa and is a good fit for such applications, offering some unique possibilities compared to most languages targeting music or audio applications. The demonstration illustrates this point by showing how simple audio blocks can be described and then interconnected in a network with dynamically changing structure, reflecting the changing demands of a musical performance.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"67 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2007-09-30","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"114245173","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
引用次数: 0
Harpy: run-time code generation in haskell hapy:在haskell中生成运行时代码
Pub Date : 2007-09-30 DOI: 10.1145/1291201.1291214
Martin Grabmüller, Dirk Kleeblatt
We present Harpy, a Haskell library for run-time code generation of x86 machine code. Harpy provides efficient generation of machine code, a convenient domain specific language for generating code and a collection of code generation combinators.
我们介绍了Harpy,一个用于x86机器码运行时代码生成的Haskell库。Harpy提供了高效的机器码生成、一种方便的用于生成代码的特定领域语言和一组代码生成组合子。
{"title":"Harpy: run-time code generation in haskell","authors":"Martin Grabmüller, Dirk Kleeblatt","doi":"10.1145/1291201.1291214","DOIUrl":"https://doi.org/10.1145/1291201.1291214","url":null,"abstract":"We present Harpy, a Haskell library for run-time code generation of x86 machine code. Harpy provides efficient generation of machine code, a convenient domain specific language for generating code and a collection of code generation combinators.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"124 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2007-09-30","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"116318259","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
引用次数: 12
Haskell' status report Haskell状态报告
Pub Date : 2006-09-17 DOI: 10.1145/1159842.1159860
Isaac Jones
The Haskell programming language is more-or-less divided into two "branches". The Haskell 98 standard is the "stable" branch of the language, and that has been a big success. A lot of progress has been made over the last few years in the "research" branch of the Haskell language. It is constantly advancing, and we feel that it is time for a new standard which reflects those advancements. This talk is a status report from the Haskell' committee to the Haskell community.
Haskell编程语言或多或少分为两个“分支”。Haskell 98标准是该语言的“稳定”分支,并且取得了巨大的成功。在过去的几年里,Haskell语言的“研究”分支取得了很大的进展。它在不断进步,我们觉得是时候制定一个反映这些进步的新标准了。这次演讲是Haskell委员会给Haskell社区的一份状态报告。
{"title":"Haskell' status report","authors":"Isaac Jones","doi":"10.1145/1159842.1159860","DOIUrl":"https://doi.org/10.1145/1159842.1159860","url":null,"abstract":"The Haskell programming language is more-or-less divided into two \"branches\". The Haskell 98 standard is the \"stable\" branch of the language, and that has been a big success. A lot of progress has been made over the last few years in the \"research\" branch of the Haskell language. It is constantly advancing, and we feel that it is time for a new standard which reflects those advancements. This talk is a status report from the Haskell' committee to the Haskell community.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"69 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2006-09-17","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"128345878","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
引用次数: 0
Polymorphic variants in Haskell Haskell中的多态变体
Pub Date : 2006-09-17 DOI: 10.1145/1159842.1159848
Koji Kagawa
In languages that support polymorphic variants, a single variant value can be passed to many contexts that accept different sets of constructors. Polymorphic variants can be used in order to introduce extensible algebraic datatypes into functional programming languages and are potentially useful for application domains such as interpreters, graphical user interface (GUI) libraries and database interfaces, where the number of necessary constructors cannot be determined in advance. Very few functional languages, however, have a mechanism to extend existing datatypes by adding new constructors. In general, for polymorphic variants to be useful, we would need some mechanisms to reuse existing functions and extend them for new constructors.Actually, the type system of Haskell, when extended with parametric type classes (or multi-parameter type classes with functional dependencies), has enough power not only to mimic polymorphic variants but also to extend existing functions for new constructors.This paper, first, explains how to do this in Haskell's type system (Haskell 98 with popular extensions). However, this encoding of polymorphic variants is difficult to use in practice. This is because it is quite tedious for programmers to write mimic codes by hand and because the problem of ambiguous overloading resolution would embarrass programmers. Therefore, the paper proposes an extension of Haskell's type classes that supports polymorphic variants directly. It has a novel form of instance declarations where records and variants are handled symmetrically.This type system can produce vanilla Haskell codes as a result of type inference. Therefore it behaves as a preprocessor which translates the extended language into plain Haskell. Programmers would be able to use polymorphic variants without worrying nasty problems such as ambiguities.
在支持多态变体的语言中,可以将单个变体值传递给接受不同构造函数集的许多上下文。多态变体可以用于在函数式编程语言中引入可扩展的代数数据类型,并且对于解释器、图形用户界面(GUI)库和数据库接口等应用程序领域具有潜在的用途,在这些领域中无法预先确定必要的构造函数的数量。然而,很少有函数式语言具有通过添加新的构造函数来扩展现有数据类型的机制。一般来说,要使多态变体有用,我们需要一些机制来重用现有函数并为新的构造函数扩展它们。实际上,Haskell的类型系统,当使用参数类型类(或带有函数依赖的多参数类型类)进行扩展时,不仅有足够的能力模拟多态变体,而且还可以为新的构造函数扩展现有的函数。本文首先解释了如何在Haskell的类型系统(Haskell 98和流行的扩展)中做到这一点。然而,这种多态变体的编码在实际应用中是困难的。这是因为程序员手工编写模拟代码非常乏味,而且模糊的重载解析问题会让程序员感到尴尬。因此,本文提出了对Haskell类型类的扩展,直接支持多态变体。它有一种新颖的实例声明形式,其中记录和变量被对称地处理。作为类型推断的结果,这个类型系统可以产生普通的Haskell代码。因此,它作为一个预处理器,将扩展语言翻译成普通的Haskell。程序员将能够使用多态变体,而不必担心诸如歧义之类的讨厌问题。
{"title":"Polymorphic variants in Haskell","authors":"Koji Kagawa","doi":"10.1145/1159842.1159848","DOIUrl":"https://doi.org/10.1145/1159842.1159848","url":null,"abstract":"In languages that support polymorphic variants, a single variant value can be passed to many contexts that accept different sets of constructors. Polymorphic variants can be used in order to introduce extensible algebraic datatypes into functional programming languages and are potentially useful for application domains such as interpreters, graphical user interface (GUI) libraries and database interfaces, where the number of necessary constructors cannot be determined in advance. Very few functional languages, however, have a mechanism to extend existing datatypes by adding new constructors. In general, for polymorphic variants to be useful, we would need some mechanisms to reuse existing functions and extend them for new constructors.Actually, the type system of Haskell, when extended with parametric type classes (or multi-parameter type classes with functional dependencies), has enough power not only to mimic polymorphic variants but also to extend existing functions for new constructors.This paper, first, explains how to do this in Haskell's type system (Haskell 98 with popular extensions). However, this encoding of polymorphic variants is difficult to use in practice. This is because it is quite tedious for programmers to write mimic codes by hand and because the problem of ambiguous overloading resolution would embarrass programmers. Therefore, the paper proposes an extension of Haskell's type classes that supports polymorphic variants directly. It has a novel form of instance declarations where records and variants are handled symmetrically.This type system can produce vanilla Haskell codes as a result of type inference. Therefore it behaves as a preprocessor which translates the extended language into plain Haskell. Programmers would be able to use polymorphic variants without worrying nasty problems such as ambiguities.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"22 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2006-09-17","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"131900841","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
引用次数: 5
Introducing the Haskell equational reasoning assistant 介绍Haskell方程推理助手
Pub Date : 2006-09-17 DOI: 10.1145/1159842.1159856
Andy Gill
We introduce the new, improved version of the Haskell Equational Reasoning Assistant, which consists of an Ajax application for rewriting Haskell fragments in their context, and an API for scripting non-trivial rewrites.
我们介绍Haskell等式推理助手的新改进版本,它包括一个Ajax应用程序,用于在上下文中重写Haskell片段,以及一个用于编写重要重写的API。
{"title":"Introducing the Haskell equational reasoning assistant","authors":"Andy Gill","doi":"10.1145/1159842.1159856","DOIUrl":"https://doi.org/10.1145/1159842.1159856","url":null,"abstract":"We introduce the new, improved version of the Haskell Equational Reasoning Assistant, which consists of an Ajax application for rewriting Haskell fragments in their context, and an API for scripting non-trivial rewrites.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"10 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2006-09-17","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"115042353","PeriodicalName":null,"FirstCategoryId":null,"ListUrlMain":null,"RegionNum":0,"RegionCategory":"","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":"","EPubDate":null,"PubModel":null,"JCR":null,"JCRName":null,"Score":null,"Total":0}
引用次数: 17
期刊
ACM SIGPLAN Symposium/Workshop on Haskell
全部 Acc. Chem. Res. ACS Applied Bio Materials ACS Appl. Electron. Mater. ACS Appl. Energy Mater. ACS Appl. Mater. Interfaces ACS Appl. Nano Mater. ACS Appl. Polym. Mater. ACS BIOMATER-SCI ENG ACS Catal. ACS Cent. Sci. ACS Chem. Biol. ACS Chemical Health & Safety ACS Chem. Neurosci. ACS Comb. Sci. ACS Earth Space Chem. ACS Energy Lett. ACS Infect. Dis. ACS Macro Lett. ACS Mater. Lett. ACS Med. Chem. Lett. ACS Nano ACS Omega ACS Photonics ACS Sens. ACS Sustainable Chem. Eng. ACS Synth. Biol. Anal. Chem. BIOCHEMISTRY-US Bioconjugate Chem. BIOMACROMOLECULES Chem. Res. Toxicol. Chem. Rev. Chem. Mater. CRYST GROWTH DES ENERG FUEL Environ. Sci. Technol. Environ. Sci. Technol. Lett. Eur. J. Inorg. Chem. IND ENG CHEM RES Inorg. Chem. J. Agric. Food. Chem. J. Chem. Eng. Data J. Chem. Educ. J. Chem. Inf. Model. J. Chem. Theory Comput. J. Med. Chem. J. Nat. Prod. J PROTEOME RES J. Am. Chem. Soc. LANGMUIR MACROMOLECULES Mol. Pharmaceutics Nano Lett. Org. Lett. ORG PROCESS RES DEV ORGANOMETALLICS J. Org. Chem. J. Phys. Chem. J. Phys. Chem. A J. Phys. Chem. B J. Phys. Chem. C J. Phys. Chem. Lett. Analyst Anal. Methods Biomater. Sci. Catal. Sci. Technol. Chem. Commun. Chem. Soc. Rev. CHEM EDUC RES PRACT CRYSTENGCOMM Dalton Trans. Energy Environ. Sci. ENVIRON SCI-NANO ENVIRON SCI-PROC IMP ENVIRON SCI-WAT RES Faraday Discuss. Food Funct. Green Chem. Inorg. Chem. Front. Integr. Biol. J. Anal. At. Spectrom. J. Mater. Chem. A J. Mater. Chem. B J. Mater. Chem. C Lab Chip Mater. Chem. Front. Mater. Horiz. MEDCHEMCOMM Metallomics Mol. Biosyst. Mol. Syst. Des. Eng. Nanoscale Nanoscale Horiz. Nat. Prod. Rep. New J. Chem. Org. Biomol. Chem. Org. Chem. Front. PHOTOCH PHOTOBIO SCI PCCP Polym. Chem.
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
0
微信
客服QQ
Book学术公众号 扫码关注我们
反馈
×
意见反馈
请填写您的意见或建议
请填写您的手机或邮箱
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
现在去查看 取消
×
提示
确定
Book学术官方微信
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术
文献互助 智能选刊 最新文献 互助须知 联系我们:info@booksci.cn
Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。
Copyright © 2023 Book学术 All rights reserved.
ghs 京公网安备 11010802042870号 京ICP备2023020795号-1