首页 > 最新文献

Proceedings of the 12th ACM SIGPLAN International Symposium on Haskell最新文献

英文 中文
Monad transformers and modular algebraic effects: what binds them together 单变量和模代数效应:是什么把它们联系在一起的
Pub Date : 2019-08-08 DOI: 10.1145/3331545.3342595
T. Schrijvers, Maciej Piróg, Nicolas Wu, Mauro Jaskelioff
For over two decades, monad transformers have been the main modular approach for expressing purely functional side-effects in Haskell. Yet, in recent years algebraic effects have emerged as an alternative whose popularity is growing. While the two approaches have been well-studied, there is still confusion about their relative merits and expressiveness, especially when it comes to their comparative modularity. This paper clarifies the connection between the two approaches—some of which is folklore—and spells out consequences that we believe should be better known. We characterise a class of algebraic effects that is modular, and show how these correspond to a specific class of monad transformers. In particular, we show that our modular algebraic effects gives rise to monad transformers. Moreover, every monad transformer for algebraic operations gives rise to a modular effect handler.
二十多年来,单子转换器一直是Haskell中表达纯功能副作用的主要模块化方法。然而,近年来,代数效应作为一种替代方法出现了,并且越来越受欢迎。虽然这两种方法已经得到了很好的研究,但它们的相对优点和表达性仍然存在混淆,特别是在它们的相对模块化方面。本文阐明了这两种方法之间的联系——其中一些是民间传说——并阐明了我们认为应该更好地了解的后果。我们描述了一类模块化的代数效应,并展示了它们如何对应于一类特定的单轴变压器。特别地,我们证明了我们的模代数效应会产生单极变压器。此外,每个用于代数运算的单子转换器都会产生一个模块效果处理程序。
{"title":"Monad transformers and modular algebraic effects: what binds them together","authors":"T. Schrijvers, Maciej Piróg, Nicolas Wu, Mauro Jaskelioff","doi":"10.1145/3331545.3342595","DOIUrl":"https://doi.org/10.1145/3331545.3342595","url":null,"abstract":"For over two decades, monad transformers have been the main modular approach for expressing purely functional side-effects in Haskell. Yet, in recent years algebraic effects have emerged as an alternative whose popularity is growing. While the two approaches have been well-studied, there is still confusion about their relative merits and expressiveness, especially when it comes to their comparative modularity. This paper clarifies the connection between the two approaches—some of which is folklore—and spells out consequences that we believe should be better known. We characterise a class of algebraic effects that is modular, and show how these correspond to a specific class of monad transformers. In particular, we show that our modular algebraic effects gives rise to monad transformers. Moreover, every monad transformer for algebraic operations gives rise to a modular effect handler.","PeriodicalId":256081,"journal":{"name":"Proceedings of the 12th ACM SIGPLAN International Symposium on Haskell","volume":"150 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2019-08-08","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"117353541","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}
引用次数: 27
Multi-stage programs in context 上下文中的多阶段程序
Pub Date : 2019-08-08 DOI: 10.1145/3331545.3342597
Matthew Pickering, Nicolas Wu, Csongor Kiss
Cross-stage persistence is an essential aspect of multi-stage programming that allows a value defined in one stage to be available in another. However, difficulty arises when implicit information held in types, type classes and implicit parameters needs to be persisted. Without a careful treatment of such implicit information---which are pervasive in Haskell---subtle yet avoidable bugs lurk beneath the surface. This paper demonstrates that in multi-stage programming care must be taken when representing quoted terms so that important implicit information is kept in context and not discarded. The approach is formalised with a type-system, and an implementation in GHC is presented that fixes problems of the previous incarnation.
跨阶段持久性是多阶段编程的一个重要方面,它允许在一个阶段定义的值在另一个阶段可用。但是,当类型、类型类和隐式参数中包含的隐式信息需要持久化时,就会出现困难。如果不仔细处理这些在Haskell中无处不在的隐性信息,那么表面之下就会潜伏着微妙但可以避免的bug。本文论证了在多阶段规划中,在表示引用项时必须注意,以使重要的隐含信息保留在上下文中而不被丢弃。该方法用类型系统形式化,并在GHC中提出了一个实现,该实现修复了前一个版本的问题。
{"title":"Multi-stage programs in context","authors":"Matthew Pickering, Nicolas Wu, Csongor Kiss","doi":"10.1145/3331545.3342597","DOIUrl":"https://doi.org/10.1145/3331545.3342597","url":null,"abstract":"Cross-stage persistence is an essential aspect of multi-stage programming that allows a value defined in one stage to be available in another. However, difficulty arises when implicit information held in types, type classes and implicit parameters needs to be persisted. Without a careful treatment of such implicit information---which are pervasive in Haskell---subtle yet avoidable bugs lurk beneath the surface. This paper demonstrates that in multi-stage programming care must be taken when representing quoted terms so that important implicit information is kept in context and not discarded. The approach is formalised with a type-system, and an implementation in GHC is presented that fixes problems of the previous incarnation.","PeriodicalId":256081,"journal":{"name":"Proceedings of the 12th ACM SIGPLAN International Symposium on Haskell","volume":"106 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2019-08-08","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"130136364","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}
引用次数: 6
G2Q: Haskell constraint solving G2Q: Haskell约束求解
Pub Date : 2019-08-08 DOI: 10.1145/3331545.3342590
William T. Hallahan, Anton Xue, R. Piskac
Constraint solvers give programmers a useful interface to solve challenging constraints at runtime. In particular, SMT solvers have been used for a vast variety of different, useful applications, ranging from strengthening Haskell's type system to verifying network protocols. Unfortunately, interacting with constraint solvers directly from Haskell requires a great deal of manual effort. Data must be represented in and translated between two forms: that understood by Haskell, and that understood by the SMT solver. Such a translation is often done via printing and parsing text, meaning that any notion of type safety is lost. Furthermore, direct translations are rarely sufficient, as it typically takes many iterations on a design in order to get optimal -- or even acceptable -- performance from a SMT solver on large scale problems. This need for iteration complicates the translation issue: it is easy to introduce a runtime bug and frustrating to fix said bug. To address these problems, we introduce a new constraint solving library, G2Q. G2Q includes a quasiquoter that allows solving constraints written in Haskell itself, thus unifying data representation, ensuring correct typing, and simplifying development iteration. We describe the API to our library and its backend. Rather than a direct translation to SMT formulas, G2Q makes use of the G2 symbolic execution engine. This allows G2Q to solve problems that are out of scope when directly encoded as SMT formulas. Finally, we demonstrate the usability of G2Q via four example programs.
约束求解器为程序员提供了一个有用的接口,以便在运行时解决具有挑战性的约束。特别是,SMT求解器已经用于各种不同的、有用的应用程序,从增强Haskell的类型系统到验证网络协议。不幸的是,直接从Haskell与约束求解器交互需要大量的手工工作。数据必须以两种形式表示并在两种形式之间转换:Haskell理解的形式和SMT求解器理解的形式。这种转换通常是通过打印和解析文本来完成的,这意味着丢失了类型安全的任何概念。此外,直接转换很少是足够的,因为在大规模问题上,为了从SMT求解器获得最佳(甚至是可接受的)性能,通常需要在设计上进行多次迭代。这种对迭代的需求使翻译问题复杂化:很容易引入运行时错误,并且修复该错误令人沮丧。为了解决这些问题,我们引入了一个新的约束求解库G2Q。G2Q包含一个准引号,允许解决用Haskell本身编写的约束,从而统一数据表示,确保正确的类型,并简化开发迭代。我们向库及其后端描述API。G2Q不是直接转换为SMT公式,而是使用G2符号执行引擎。这允许G2Q解决直接编码为SMT公式时超出范围的问题。最后,我们通过四个示例程序演示G2Q的可用性。
{"title":"G2Q: Haskell constraint solving","authors":"William T. Hallahan, Anton Xue, R. Piskac","doi":"10.1145/3331545.3342590","DOIUrl":"https://doi.org/10.1145/3331545.3342590","url":null,"abstract":"Constraint solvers give programmers a useful interface to solve challenging constraints at runtime. In particular, SMT solvers have been used for a vast variety of different, useful applications, ranging from strengthening Haskell's type system to verifying network protocols. Unfortunately, interacting with constraint solvers directly from Haskell requires a great deal of manual effort. Data must be represented in and translated between two forms: that understood by Haskell, and that understood by the SMT solver. Such a translation is often done via printing and parsing text, meaning that any notion of type safety is lost. Furthermore, direct translations are rarely sufficient, as it typically takes many iterations on a design in order to get optimal -- or even acceptable -- performance from a SMT solver on large scale problems. This need for iteration complicates the translation issue: it is easy to introduce a runtime bug and frustrating to fix said bug. To address these problems, we introduce a new constraint solving library, G2Q. G2Q includes a quasiquoter that allows solving constraints written in Haskell itself, thus unifying data representation, ensuring correct typing, and simplifying development iteration. We describe the API to our library and its backend. Rather than a direct translation to SMT formulas, G2Q makes use of the G2 symbolic execution engine. This allows G2Q to solve problems that are out of scope when directly encoded as SMT formulas. Finally, we demonstrate the usability of G2Q via four example programs.","PeriodicalId":256081,"journal":{"name":"Proceedings of the 12th ACM SIGPLAN International Symposium on Haskell","volume":"33 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2019-08-08","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"134543032","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
Formal verification of spacecraft control programs (experience report) 航天器控制程序的正式验证(经验报告)
Pub Date : 2019-08-08 DOI: 10.1145/3331545.3342593
A. Mokhov, G. Lukyanov, J. Lechner
Verification of correctness of control programs is an essential task in the development of space electronics; it is difficult and typically outweighs design and programming tasks in terms of development hours. This experience report presents a verification approach designed to help spacecraft engineers reduce the effort required for formal verification of low-level control programs executed on custom hardware. The verification approach is demonstrated on an industrial case study. We present REDFIN, a processing core used in space missions, and its formal semantics expressed using the proposed metalanguage for state transformers, followed by examples of verification of simple control programs.
验证控制程序的正确性是空间电子学发展的一项重要任务;就开发时间而言,这是困难的,并且通常超过了设计和编程任务。本经验报告提出了一种验证方法,旨在帮助航天器工程师减少对在定制硬件上执行的低级控制程序进行正式验证所需的工作量。验证方法在一个工业案例研究中得到了验证。我们介绍了REDFIN,一个用于空间任务的处理核心,以及使用所提出的状态转换器元语言表达的形式语义,然后是简单控制程序验证的示例。
{"title":"Formal verification of spacecraft control programs (experience report)","authors":"A. Mokhov, G. Lukyanov, J. Lechner","doi":"10.1145/3331545.3342593","DOIUrl":"https://doi.org/10.1145/3331545.3342593","url":null,"abstract":"Verification of correctness of control programs is an essential task in the development of space electronics; it is difficult and typically outweighs design and programming tasks in terms of development hours. This experience report presents a verification approach designed to help spacecraft engineers reduce the effort required for formal verification of low-level control programs executed on custom hardware. The verification approach is demonstrated on an industrial case study. We present REDFIN, a processing core used in space missions, and its formal semantics expressed using the proposed metalanguage for state transformers, followed by examples of verification of simple control programs.","PeriodicalId":256081,"journal":{"name":"Proceedings of the 12th ACM SIGPLAN International Symposium on Haskell","volume":"699 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2019-08-08","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"116105372","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}
引用次数: 4
Scoping monadic relational database queries 限定一元关系数据库查询的范围
Pub Date : 2019-08-08 DOI: 10.1145/3331545.3342598
A. Ekblad
We present a novel method for ensuring that relational database queries in monadic embedded languages are well-scoped, even in the presence of arbitrarily nested joins and aggregates. Demonstrating our method, we present a simplified version of Selda, a monadic relational database query language embedded in Haskell, with full support for nested inner queries. To our knowledge, Selda is the first relational database query language to support fully general inner queries using a monadic interface. In the Haskell community, monads are the de facto standard interface to a wide range of libraries and EDSLs. They are well understood by researchers and practitioners alike, and they enjoy first class support by the standard libraries. Due to the difficulty of ensuring that inner queries are well-scoped, database interfaces in Haskell have previously either been forced to forego the benefits of monadic interfaces, or have had to do without the generality afforded by inner queries.
我们提出了一种新的方法来确保一元嵌入式语言中的关系数据库查询具有良好的作用域,即使存在任意嵌套的连接和聚合。为了演示我们的方法,我们展示了Selda的简化版本,Selda是一种嵌入在Haskell中的一元关系数据库查询语言,完全支持嵌套内部查询。据我们所知,Selda是第一个使用一元接口完全支持一般内部查询的关系数据库查询语言。在Haskell社区中,monad是各种库和edsl的事实上的标准接口。研究人员和实践者都能很好地理解它们,并且它们享有标准库的一流支持。由于难以确保内部查询具有良好的作用域,Haskell中的数据库接口以前要么被迫放弃一元接口的好处,要么不得不放弃内部查询所提供的通用性。
{"title":"Scoping monadic relational database queries","authors":"A. Ekblad","doi":"10.1145/3331545.3342598","DOIUrl":"https://doi.org/10.1145/3331545.3342598","url":null,"abstract":"We present a novel method for ensuring that relational database queries in monadic embedded languages are well-scoped, even in the presence of arbitrarily nested joins and aggregates. Demonstrating our method, we present a simplified version of Selda, a monadic relational database query language embedded in Haskell, with full support for nested inner queries. To our knowledge, Selda is the first relational database query language to support fully general inner queries using a monadic interface. In the Haskell community, monads are the de facto standard interface to a wide range of libraries and EDSLs. They are well understood by researchers and practitioners alike, and they enjoy first class support by the standard libraries. Due to the difficulty of ensuring that inner queries are well-scoped, database interfaces in Haskell have previously either been forced to forego the benefits of monadic interfaces, or have had to do without the generality afforded by inner queries.","PeriodicalId":256081,"journal":{"name":"Proceedings of the 12th ACM SIGPLAN International Symposium on Haskell","volume":"227 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2019-08-08","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"132173722","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
Making a faster Curry with extensional types 用扩展类型制作更快的咖喱
Pub Date : 2019-08-08 DOI: 10.1145/3331545.3342594
P. Downen, Zachary J. Sullivan, Z. M. Ariola, S. Jones
Curried functions apparently take one argument at a time, which is slow. So optimizing compilers for higher-order languages invariably have some mechanism for working around currying by passing several arguments at once, as many as the function can handle, which is known as its arity. But such mechanisms are often ad-hoc, and do not work at all in higher-order functions. We show how extensional, call-by-name functions have the correct behavior for directly expressing the arity of curried functions. And these extensional functions can stand side-by-side with functions native to practical programming languages, which do not use call-by-name evaluation. Integrating call-by-name with other evaluation strategies in the same intermediate language expresses the arity of a function in its type and gives a principled and compositional account of multi-argument curried functions. An unexpected, but significant, bonus is that our approach is equally suitable for a call-by-value language and a call-by-need language, and it can be readily integrated into an existing compilation framework.
显然,curry函数一次只接受一个参数,速度很慢。因此,高阶语言的优化编译器总是有一些机制,通过一次传递多个参数来解决柯里化问题,函数可以处理多少就传递多少,这被称为它的性。但这种机制通常是临时的,在高阶函数中根本不起作用。我们将展示扩展的、按名称调用的函数如何具有直接表示柯里化函数的性的正确行为。这些扩展函数可以与实际编程语言的原生函数并排使用,这些函数不使用按名称调用求值。将名称调用与同一中间语言中的其他求值策略集成在一起,表达了函数在其类型中的性,并给出了多参数柯里化函数的原则性和组合性说明。一个意想不到但意义重大的好处是,我们的方法同样适用于按值调用语言和按需求调用语言,并且它可以很容易地集成到现有的编译框架中。
{"title":"Making a faster Curry with extensional types","authors":"P. Downen, Zachary J. Sullivan, Z. M. Ariola, S. Jones","doi":"10.1145/3331545.3342594","DOIUrl":"https://doi.org/10.1145/3331545.3342594","url":null,"abstract":"Curried functions apparently take one argument at a time, which is slow. So optimizing compilers for higher-order languages invariably have some mechanism for working around currying by passing several arguments at once, as many as the function can handle, which is known as its arity. But such mechanisms are often ad-hoc, and do not work at all in higher-order functions. We show how extensional, call-by-name functions have the correct behavior for directly expressing the arity of curried functions. And these extensional functions can stand side-by-side with functions native to practical programming languages, which do not use call-by-name evaluation. Integrating call-by-name with other evaluation strategies in the same intermediate language expresses the arity of a function in its type and gives a principled and compositional account of multi-argument curried functions. An unexpected, but significant, bonus is that our approach is equally suitable for a call-by-value language and a call-by-need language, and it can be readily integrated into an existing compilation framework.","PeriodicalId":256081,"journal":{"name":"Proceedings of the 12th ACM SIGPLAN International Symposium on Haskell","volume":"247 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2019-08-08","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"131357685","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}
引用次数: 6
Generic and flexible defaults for verified, law-abiding type-class instances 用于经过验证的、遵守法律的类型类实例的通用且灵活的默认值
Pub Date : 2019-08-08 DOI: 10.1145/3331545.3342591
Ryan G. Scott, Ryan Newton
Dependently typed languages allow programmers to state and prove type class laws by simply encoding the laws as class methods. But writing implementations of these methods frequently give way to large amounts of routine, boilerplate code, and depending on the law involved, the size of these proofs can grow superlinearly with the size of the datatypes involved. We present a technique for automating away large swaths of this boilerplate by leveraging datatype-generic programming. We observe that any algebraic data type has an equivalent representation type that is composed of simpler, smaller types that are simpler to prove theorems over. By constructing an isomorphism between a datatype and its representation type, we derive proofs for the original datatype by reusing the corresponding proof over the representation type. Our work is designed to be general-purpose and does not require advanced automation techniques such as tactic systems. As evidence for this claim, we implement these ideas in a Haskell library that defines generic, canonical implementations of the methods and proof obligations for classes in the standard base library.
依赖类型语言允许程序员通过简单地将这些规则编码为类方法来声明和证明类型类规则。但是,编写这些方法的实现常常会让位于大量的例程和样板代码,并且根据所涉及的规律,这些证明的大小可能会随着所涉及的数据类型的大小超线性地增长。我们提出了一种技术,通过利用数据类型泛型编程来自动删除该样板的大部分内容。我们观察到,任何代数数据类型都有一个等效的表示类型,它由更简单、更小的类型组成,更容易证明定理。通过构造数据类型与其表示类型之间的同构,我们通过在表示类型上重用相应的证明来推导原始数据类型的证明。我们的工作被设计成通用的,不需要先进的自动化技术,如战术系统。作为这种说法的证据,我们在一个Haskell库中实现了这些想法,该库定义了标准基库中方法的通用、规范实现和类的证明义务。
{"title":"Generic and flexible defaults for verified, law-abiding type-class instances","authors":"Ryan G. Scott, Ryan Newton","doi":"10.1145/3331545.3342591","DOIUrl":"https://doi.org/10.1145/3331545.3342591","url":null,"abstract":"Dependently typed languages allow programmers to state and prove type class laws by simply encoding the laws as class methods. But writing implementations of these methods frequently give way to large amounts of routine, boilerplate code, and depending on the law involved, the size of these proofs can grow superlinearly with the size of the datatypes involved. We present a technique for automating away large swaths of this boilerplate by leveraging datatype-generic programming. We observe that any algebraic data type has an equivalent representation type that is composed of simpler, smaller types that are simpler to prove theorems over. By constructing an isomorphism between a datatype and its representation type, we derive proofs for the original datatype by reusing the corresponding proof over the representation type. Our work is designed to be general-purpose and does not require advanced automation techniques such as tactic systems. As evidence for this claim, we implement these ideas in a Haskell library that defines generic, canonical implementations of the methods and proof obligations for classes in the standard base library.","PeriodicalId":256081,"journal":{"name":"Proceedings of the 12th ACM SIGPLAN International Symposium on Haskell","volume":"26 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2019-08-08","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"114181293","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}
引用次数: 1
Verifying effectful Haskell programs in Coq 验证Coq中有效的Haskell程序
Pub Date : 2019-08-08 DOI: 10.1145/3331545.3342592
Jan Christiansen, Sandra Dylus, Niels Bunkenburg
We show how various Haskell language features that are related to ambient effects can be modeled in Coq. For this purpose we build on previous work that demonstrates how to reason about existing Haskell programs by translating them into monadic Coq programs. A model of Haskell programs in Coq that is polymorphic over an arbitrary monad results in non-strictly positive types when transforming recursive data types likes lists. Such non-strictly positive types are not accepted by Coq's termination checker. Therefore, instead of a model that is generic over any monad, the approach we build on uses a specific monad instance, namely the free monad in combination with containers, to model various kinds of effects. This model allows effect-generic proofs. In this paper we consider ambient effects that may occur in Haskell, namely partiality, errors, and tracing, in detail. We observe that, while proving propositions that hold for all kinds of effects is attractive, not all propositions of interest hold for all kinds of effects. Some propositions fail for certain effects because the usual monadic translation models call-by-name and not call-by-need. Since modeling the evaluation semantics of call-by-need in the presence of effects like partiality is complex and not necessary to prove propositions for a variety of effects, we identify a specific class of effects for which we cannot observe a difference between call-by-name and call-by-need. Using this class of effects we can prove propositions for all effects that do not require a model of sharing.
我们展示了如何在Coq中建模与环境效果相关的各种Haskell语言特性。为了达到这个目的,我们在之前的工作的基础上,演示了如何通过将现有的Haskell程序翻译成一元Coq程序来推断它们。Coq中的Haskell程序模型在任意单子上是多态的,当转换递归数据类型(如列表)时,会产生非严格正类型。Coq的终止检查器不接受这种非严格阳性类型。因此,我们构建的方法不是在任何monad上通用的模型,而是使用特定的monad实例,即结合了容器的自由monad,来模拟各种效果。这个模型允许效应泛型证明。在本文中,我们详细考虑了在Haskell中可能发生的环境效应,即偏袒,错误和跟踪。我们观察到,虽然证明对所有效应都成立的命题是有吸引力的,但并不是所有感兴趣的命题都对所有效应成立。由于通常的一元翻译模式是按名称调用而不是按需要调用,所以有些命题在某些效果上失败了。由于在存在偏好等效应的情况下对按需呼叫的评估语义进行建模是复杂的,并且对于证明各种效应的命题是不必要的,因此我们确定了一类特定的效应,我们无法观察到按名呼叫和按需呼叫之间的差异。利用这类效应,我们可以证明不需要共享模型的所有效应的命题。
{"title":"Verifying effectful Haskell programs in Coq","authors":"Jan Christiansen, Sandra Dylus, Niels Bunkenburg","doi":"10.1145/3331545.3342592","DOIUrl":"https://doi.org/10.1145/3331545.3342592","url":null,"abstract":"We show how various Haskell language features that are related to ambient effects can be modeled in Coq. For this purpose we build on previous work that demonstrates how to reason about existing Haskell programs by translating them into monadic Coq programs. A model of Haskell programs in Coq that is polymorphic over an arbitrary monad results in non-strictly positive types when transforming recursive data types likes lists. Such non-strictly positive types are not accepted by Coq's termination checker. Therefore, instead of a model that is generic over any monad, the approach we build on uses a specific monad instance, namely the free monad in combination with containers, to model various kinds of effects. This model allows effect-generic proofs. In this paper we consider ambient effects that may occur in Haskell, namely partiality, errors, and tracing, in detail. We observe that, while proving propositions that hold for all kinds of effects is attractive, not all propositions of interest hold for all kinds of effects. Some propositions fail for certain effects because the usual monadic translation models call-by-name and not call-by-need. Since modeling the evaluation semantics of call-by-need in the presence of effects like partiality is complex and not necessary to prove propositions for a variety of effects, we identify a specific class of effects for which we cannot observe a difference between call-by-name and call-by-need. Using this class of effects we can prove propositions for all effects that do not require a model of sharing.","PeriodicalId":256081,"journal":{"name":"Proceedings of the 12th ACM SIGPLAN International Symposium on Haskell","volume":"151 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2019-08-08","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"116280246","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}
引用次数: 4
Working with source plugins 使用源插件
Pub Date : 2019-08-08 DOI: 10.1145/3331545.3342599
Matthew Pickering, Nicolas Wu, Boldizsár Németh
A modern compiler calculates and constructs a large amount of information about the programs it compiles. Tooling authors want to take advantage of this information in order to extend the compiler in interesting ways. Source plugins are a mechanism implemented in the Glasgow Haskell Compiler (GHC) which allow inspection and modification of programs as they pass through the compilation pipeline. This paper is about how to write source plugins. Due to their nature—they are ways to extend the compiler—at least basic knowledge about how the compiler works is critical to designing and implementing a robust and therefore successful plugin. The goal of the paper is to equip would-be plugin authors with inspiration about what kinds of plugins they should write and most importantly with the basic techniques which should be used in order to write them.
现代编译器计算和构造关于它所编译的程序的大量信息。工具作者希望利用这些信息,以有趣的方式扩展编译器。源插件是在格拉斯哥Haskell编译器(GHC)中实现的一种机制,它允许在程序通过编译管道时检查和修改程序。本文是关于如何编写源代码插件。由于它们的性质——它们是扩展编译器的方式——至少了解编译器如何工作对于设计和实现一个健壮的、成功的插件是至关重要的。这篇文章的目的是给想要成为插件作者的人一些启发,告诉他们应该写什么样的插件,最重要的是告诉他们在写插件时应该使用的基本技术。
{"title":"Working with source plugins","authors":"Matthew Pickering, Nicolas Wu, Boldizsár Németh","doi":"10.1145/3331545.3342599","DOIUrl":"https://doi.org/10.1145/3331545.3342599","url":null,"abstract":"A modern compiler calculates and constructs a large amount of information about the programs it compiles. Tooling authors want to take advantage of this information in order to extend the compiler in interesting ways. Source plugins are a mechanism implemented in the Glasgow Haskell Compiler (GHC) which allow inspection and modification of programs as they pass through the compilation pipeline. This paper is about how to write source plugins. Due to their nature—they are ways to extend the compiler—at least basic knowledge about how the compiler works is critical to designing and implementing a robust and therefore successful plugin. The goal of the paper is to equip would-be plugin authors with inspiration about what kinds of plugins they should write and most importantly with the basic techniques which should be used in order to write them.","PeriodicalId":256081,"journal":{"name":"Proceedings of the 12th ACM SIGPLAN International Symposium on Haskell","volume":"1 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2019-08-08","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"129473471","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}
引用次数: 6
Bidirectional type class instances 双向类型类实例
Pub Date : 2019-08-08 DOI: 10.1145/3331545.3342596
Koen Pauwels, G. Karachalias, Michiel Derhaeg, T. Schrijvers
GADTs were introduced in Haskell’s eco-system more than a decade ago, but their interaction with several mainstream features such as type classes and functional dependencies has a lot of room for improvement. More specifically, for some GADTs it can be surprisingly difficult to provide an instance for even the simplest of type classes. In this paper we identify the source of this shortcoming and address it by introducing a conservative extension to Haskell’s type classes: Bidirectional Type Class Instances. In essence, under our interpretation class instances correspond to logical bi-implications, in contrast to their traditional unidirectional interpretation. We present a fully-fledged design of bidirectional instances, covering the specification of typing and elaboration into System FC, as well as an algorithm for type inference and elaboration. We provide a proof-of-concept implementation of our algorithm, and revisit the meta-theory of type classes in the presence of our extension.
早在十多年前,gadt就被引入Haskell的生态系统中,但是它们与几个主流特性(如类型类和函数依赖)的交互还有很大的改进空间。更具体地说,对于某些gdt来说,即使是最简单的类型类也很难提供实例。在本文中,我们确定了这个缺点的来源,并通过向Haskell的类型类引入一个保守的扩展来解决它:双向类型类实例。本质上,在我们的解释下,类实例对应于逻辑双向含义,而不是传统的单向解释。我们提出了一个完整的双向实例设计,涵盖了系统FC的类型和细化的规范,以及类型推断和细化的算法。我们提供了算法的概念验证实现,并在我们的扩展中重新审视类型类的元理论。
{"title":"Bidirectional type class instances","authors":"Koen Pauwels, G. Karachalias, Michiel Derhaeg, T. Schrijvers","doi":"10.1145/3331545.3342596","DOIUrl":"https://doi.org/10.1145/3331545.3342596","url":null,"abstract":"GADTs were introduced in Haskell’s eco-system more than a decade ago, but their interaction with several mainstream features such as type classes and functional dependencies has a lot of room for improvement. More specifically, for some GADTs it can be surprisingly difficult to provide an instance for even the simplest of type classes. In this paper we identify the source of this shortcoming and address it by introducing a conservative extension to Haskell’s type classes: Bidirectional Type Class Instances. In essence, under our interpretation class instances correspond to logical bi-implications, in contrast to their traditional unidirectional interpretation. We present a fully-fledged design of bidirectional instances, covering the specification of typing and elaboration into System FC, as well as an algorithm for type inference and elaboration. We provide a proof-of-concept implementation of our algorithm, and revisit the meta-theory of type classes in the presence of our extension.","PeriodicalId":256081,"journal":{"name":"Proceedings of the 12th ACM SIGPLAN International Symposium on Haskell","volume":"30 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2019-08-08","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"129647052","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
期刊
Proceedings of the 12th ACM SIGPLAN International Symposium 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