首页 > 最新文献

ACM SIGPLAN Symposium/Workshop on Haskell最新文献

英文 中文
Monoids: theme and variations (functional pearl) Monoids:主题和变型(功能性珍珠)
Pub Date : 2013-01-17 DOI: 10.1145/2364506.2364520
Brent A. Yorgey
The monoid is a humble algebraic structure, at first glance even downright boring. However, there's much more to monoids than meets the eye. Using examples taken from the diagrams vector graphics framework as a case study, I demonstrate the power and beauty of monoids for library design. The paper begins with an extremely simple model of diagrams and proceeds through a series of incremental variations, all related somehow to the central theme of monoids. Along the way, I illustrate the power of compositional semantics; why you should also pay attention to the monoid's even humbler cousin, the semigroup; monoid homomorphisms; and monoid actions.
一元群是一个不起眼的代数结构,乍一看甚至是彻头彻尾的无聊。然而,单群鱼远比我们看到的要复杂。使用从图表矢量图形框架中提取的例子作为案例研究,我展示了monoids在图书馆设计中的力量和美丽。这篇论文从一个极其简单的图表模型开始,并通过一系列增量变化进行,所有这些都与一元群的中心主题有关。在此过程中,我说明了组合语义的力量;为什么你也要注意单群的表亲,半群;独异点同态;和单动作。
{"title":"Monoids: theme and variations (functional pearl)","authors":"Brent A. Yorgey","doi":"10.1145/2364506.2364520","DOIUrl":"https://doi.org/10.1145/2364506.2364520","url":null,"abstract":"The monoid is a humble algebraic structure, at first glance even downright boring. However, there's much more to monoids than meets the eye. Using examples taken from the diagrams vector graphics framework as a case study, I demonstrate the power and beauty of monoids for library design. The paper begins with an extremely simple model of diagrams and proceeds through a series of incremental variations, all related somehow to the central theme of monoids. Along the way, I illustrate the power of compositional semantics; why you should also pay attention to the monoid's even humbler cousin, the semigroup; monoid homomorphisms; and monoid actions.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"8 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2013-01-17","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"131909351","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
Wormholes: introducing effects to FRP 虫洞:引入玻璃钢效果
Pub Date : 2013-01-17 DOI: 10.1145/2364506.2364519
Daniel Winograd-Cort, P. Hudak
Functional reactive programming (FRP) is a useful model for programming real-time and reactive systems in which one defines a signal function to process a stream of input values into a stream of output values. However, performing side effects (e.g. memory mutation or input/output) in this model is tricky and typically unsafe. In previous work, Winograd-Cort et al. [2012] introduced resource types and wormholes to address this problem. This paper better motivates, expands upon, and formalizes the notion of a wormhole to fully unlock its potential. We show, for example, that wormholes can be used to define the concept of causality. This in turn allows us to provide behaviors such as looping, a core component of most languages, without building it directly into the language. We also improve upon our previous design by making wormholes less verbose and easier to use. To formalize the notion of a wormhole, we define an extension to the simply typed lambda calculus, complete with typing rules and operational semantics. In addition, we present a new form of semantic transition that we call a temporal transition to specify how an FRP program behaves over time and to allow us to better reason about causality. As our model is designed for a Haskell implementation, the semantics are lazy. Finally, with the language defined, we prove that our wormholes indeed allow side effects to be performed safely in an FRP framework.
函数式反应性编程(FRP)是一种用于实时和反应性系统编程的有用模型,其中定义了一个信号函数来将输入值流处理成输出值流。然而,在这个模型中执行副作用(例如内存突变或输入/输出)是棘手的,通常是不安全的。在之前的工作中,Winograd-Cort等人[2012]引入了资源类型和虫洞来解决这个问题。本文更好地激发、扩展和形式化了虫洞的概念,以充分释放其潜力。例如,我们展示了虫洞可以用来定义因果关系的概念。这反过来又允许我们提供循环之类的行为,这是大多数语言的核心组件,而无需将其直接构建到语言中。我们还改进了以前的设计,使虫洞更简洁,更易于使用。为了形式化虫洞的概念,我们定义了简单类型lambda演算的扩展,其中包括类型规则和操作语义。此外,我们提出了一种新的语义转换形式,我们称之为时间转换,以指定FRP程序随时间的行为,并允许我们更好地推理因果关系。由于我们的模型是为Haskell实现设计的,所以语义是惰性的。最后,通过定义语言,我们证明虫洞确实允许在FRP框架中安全地执行副作用。
{"title":"Wormholes: introducing effects to FRP","authors":"Daniel Winograd-Cort, P. Hudak","doi":"10.1145/2364506.2364519","DOIUrl":"https://doi.org/10.1145/2364506.2364519","url":null,"abstract":"Functional reactive programming (FRP) is a useful model for programming real-time and reactive systems in which one defines a signal function to process a stream of input values into a stream of output values. However, performing side effects (e.g. memory mutation or input/output) in this model is tricky and typically unsafe. In previous work, Winograd-Cort et al. [2012] introduced resource types and wormholes to address this problem.\u0000 This paper better motivates, expands upon, and formalizes the notion of a wormhole to fully unlock its potential. We show, for example, that wormholes can be used to define the concept of causality. This in turn allows us to provide behaviors such as looping, a core component of most languages, without building it directly into the language. We also improve upon our previous design by making wormholes less verbose and easier to use.\u0000 To formalize the notion of a wormhole, we define an extension to the simply typed lambda calculus, complete with typing rules and operational semantics. In addition, we present a new form of semantic transition that we call a temporal transition to specify how an FRP program behaves over time and to allow us to better reason about causality. As our model is designed for a Haskell implementation, the semantics are lazy. Finally, with the language defined, we prove that our wormholes indeed allow side effects to be performed safely in an FRP framework.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"31 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2013-01-17","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"123444951","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}
引用次数: 8
Layout-sensitive language extensibility with SugarHaskell SugarHaskell的布局敏感语言可扩展性
Pub Date : 2013-01-17 DOI: 10.1145/2364506.2364526
Sebastian Erdweg, F. Rieger, Tillmann Rendel, K. Ostermann
Programmers need convenient syntax to write elegant and concise programs. Consequently, the Haskell standard provides syntactic sugar for some scenarios (e.g., do notation for monadic code), authors of Haskell compilers provide syntactic sugar for more scenarios (e.g., arrow notation in GHC), and some Haskell programmers implement preprocessors for their individual needs (e.g., idiom brackets in SHE). But manually written preprocessors cannot scale: They are expensive, error-prone, and not composable. Most researchers and programmers therefore refrain from using the syntactic notations they need in actual Haskell programs, but only use them in documentation or papers. We present a syntactically extensible version of Haskell, SugarHaskell, that empowers ordinary programmers to implement and use custom syntactic sugar. Building on our previous work on syntactic extensibility for Java, SugarHaskell integrates syntactic extensions as sugar libraries into Haskell's module system. Syntax extensions in SugarHaskell can declare arbitrary context-free and layout-sensitive syntax. SugarHaskell modules are compiled into Haskell modules and further processed by a Haskell compiler. We provide an Eclipse-based IDE for SugarHaskell that is extensible, too, and automatically provides syntax coloring for all syntax extensions imported into a module. We have validated SugarHaskell with several case studies, including arrow notation (as implemented in GHC) and EBNF as a concise syntax for the declaration of algebraic data types with associated concrete syntax. EBNF declarations also show how to extend the extension mechanism itself: They introduce syntactic sugar for using the declared concrete syntax in other SugarHaskell modules.
程序员需要方便的语法来编写优雅而简洁的程序。因此,Haskell标准为某些场景提供了语法糖(例如,一元代码的do表示法),Haskell编译器的作者为更多场景提供了语法糖(例如,GHC中的箭头表示法),一些Haskell程序员为他们的个人需求实现了预处理器(例如,SHE中的习语括号)。但是手工编写的预处理器无法扩展:它们昂贵、容易出错,而且不可组合。因此,大多数研究人员和程序员都避免在实际的Haskell程序中使用他们需要的语法符号,而只在文档或论文中使用它们。我们提供了Haskell的一个语法可扩展版本SugarHaskell,它使普通程序员能够实现和使用自定义语法糖。在我们之前关于Java语法可扩展性工作的基础上,SugarHaskell将语法扩展作为糖库集成到Haskell的模块系统中。SugarHaskell中的语法扩展可以声明任意上下文无关和布局敏感的语法。SugarHaskell模块被编译成Haskell模块,并由Haskell编译器进一步处理。我们为SugarHaskell提供了一个基于eclipse的IDE,它也是可扩展的,并自动为导入到模块中的所有语法扩展提供语法着色。我们已经用几个案例研究验证了SugarHaskell,包括箭头表示法(在GHC中实现)和EBNF,它是一种简洁的语法,用于声明具有相关具体语法的代数数据类型。EBNF声明还展示了如何扩展扩展机制本身:它们引入了语法糖,以便在其他SugarHaskell模块中使用声明的具体语法。
{"title":"Layout-sensitive language extensibility with SugarHaskell","authors":"Sebastian Erdweg, F. Rieger, Tillmann Rendel, K. Ostermann","doi":"10.1145/2364506.2364526","DOIUrl":"https://doi.org/10.1145/2364506.2364526","url":null,"abstract":"Programmers need convenient syntax to write elegant and concise programs. Consequently, the Haskell standard provides syntactic sugar for some scenarios (e.g., do notation for monadic code), authors of Haskell compilers provide syntactic sugar for more scenarios (e.g., arrow notation in GHC), and some Haskell programmers implement preprocessors for their individual needs (e.g., idiom brackets in SHE). But manually written preprocessors cannot scale: They are expensive, error-prone, and not composable. Most researchers and programmers therefore refrain from using the syntactic notations they need in actual Haskell programs, but only use them in documentation or papers. We present a syntactically extensible version of Haskell, SugarHaskell, that empowers ordinary programmers to implement and use custom syntactic sugar.\u0000 Building on our previous work on syntactic extensibility for Java, SugarHaskell integrates syntactic extensions as sugar libraries into Haskell's module system. Syntax extensions in SugarHaskell can declare arbitrary context-free and layout-sensitive syntax. SugarHaskell modules are compiled into Haskell modules and further processed by a Haskell compiler. We provide an Eclipse-based IDE for SugarHaskell that is extensible, too, and automatically provides syntax coloring for all syntax extensions imported into a module.\u0000 We have validated SugarHaskell with several case studies, including arrow notation (as implemented in GHC) and EBNF as a concise syntax for the declaration of algebraic data types with associated concrete syntax. EBNF declarations also show how to extend the extension mechanism itself: They introduce syntactic sugar for using the declared concrete syntax in other SugarHaskell modules.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"64 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2013-01-17","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"130646347","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}
引用次数: 18
Vectorisation avoidance 避免矢量化
Pub Date : 2013-01-17 DOI: 10.1145/2364506.2364512
G. Keller, M. Chakravarty, Roman Leshchinskiy, B. Lippmeier, S. Jones
Flattening nested parallelism is a vectorising code transform that converts irregular nested parallelism into flat data parallelism. Although the result has good asymptotic performance, flattening thoroughly restructures the code. Many intermediate data structures and traversals are introduced, which may or may not be eliminated by subsequent optimisation. We present a novel program analysis to identify parts of the program where flattening would only introduce overhead, without appropriate gain. We present empirical evidence that avoiding vectorisation in these cases leads to more efficient programs than if we had applied vectorisation and then relied on array fusion to eliminate intermediates from the resulting code.
扁平化嵌套并行是一种向量化代码转换,它将不规则的嵌套并行转换为扁平的数据并行。虽然结果具有良好的渐近性能,但扁平化彻底地重构了代码。引入了许多中间数据结构和遍历,这些可能会被后续的优化消除,也可能不会。我们提出了一种新颖的程序分析,以确定程序中扁平化只会引入开销而没有适当增益的部分。我们提出的经验证据表明,在这些情况下,避免向量化比我们应用向量化然后依靠数组融合来消除结果代码中的中间部分更有效。
{"title":"Vectorisation avoidance","authors":"G. Keller, M. Chakravarty, Roman Leshchinskiy, B. Lippmeier, S. Jones","doi":"10.1145/2364506.2364512","DOIUrl":"https://doi.org/10.1145/2364506.2364512","url":null,"abstract":"Flattening nested parallelism is a vectorising code transform that converts irregular nested parallelism into flat data parallelism. Although the result has good asymptotic performance, flattening thoroughly restructures the code. Many intermediate data structures and traversals are introduced, which may or may not be eliminated by subsequent optimisation. We present a novel program analysis to identify parts of the program where flattening would only introduce overhead, without appropriate gain. We present empirical evidence that avoiding vectorisation in these cases leads to more efficient programs than if we had applied vectorisation and then relied on array fusion to eliminate intermediates from the resulting code.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"49 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2013-01-17","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"133599347","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
Testing type class laws 试验型式等级法
Pub Date : 2013-01-17 DOI: 10.1145/2364506.2364514
J. Jeuring, Patrik Jansson, C. Amaral
The specification of a class in Haskell often starts with stating, in comments, the laws that should be satisfied by methods defined in instances of the class, followed by the type of the methods of the class. This paper develops a framework that supports testing such class laws using QuickCheck. Our framework is a light-weight class law testing framework, which requires a limited amount of work per class law, and per datatype for which the class law is tested. We also show how to test class laws with partially-defined values. Using partially-defined values, we show that the standard lazy and strict implementations of the state monad do not satisfy the expected laws.
在Haskell中,类的规范通常首先在注释中说明类实例中定义的方法应该满足的规律,然后是类方法的类型。本文开发了一个支持使用QuickCheck测试此类类律的框架。我们的框架是一个轻量级的类法测试框架,它只需要对每个类法和每个测试类法的数据类型做有限的工作。我们还展示了如何用部分定义的值测试类律。使用部分定义的值,我们证明了状态单子的标准惰性和严格实现不满足预期的规律。
{"title":"Testing type class laws","authors":"J. Jeuring, Patrik Jansson, C. Amaral","doi":"10.1145/2364506.2364514","DOIUrl":"https://doi.org/10.1145/2364506.2364514","url":null,"abstract":"The specification of a class in Haskell often starts with stating, in comments, the laws that should be satisfied by methods defined in instances of the class, followed by the type of the methods of the class. This paper develops a framework that supports testing such class laws using QuickCheck. Our framework is a light-weight class law testing framework, which requires a limited amount of work per class law, and per datatype for which the class law is tested. We also show how to test class laws with partially-defined values. Using partially-defined values, we show that the standard lazy and strict implementations of the state monad do not satisfy the expected laws.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"1 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2013-01-17","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"129221960","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
Embedded parser generators 嵌入式解析器生成器
Pub Date : 2012-01-12 DOI: 10.1145/2034675.2034689
Jonas Duregård, Patrik Jansson
We present a novel method of embedding context-free grammars in Haskell, and to automatically generate parsers and pretty-printers from them. We have implemented this method in a library called BNFC-meta (from the BNF Converter, which it is built on). The library builds compiler front ends using metaprogramming instead of conventional code generation. Parsers are built from labelled BNF grammars that are defined directly in Haskell modules. Our solution combines features of parser generators (static grammar checks, a highly specialised grammar DSL) and adds several features that are otherwise exclusive to combinatory libraries such as the ability to reuse, parameterise and generate grammars inside Haskell. To allow writing grammars in concrete syntax, BNFC-meta provides a quasi-quoter that can parse grammars (embedded in Haskell files) at compile time and use metaprogramming to replace them with their abstract syntax. We also generate quasi-quoters so that the languages we define with BNFC-meta can be embedded in the same way. With a minimal change to the grammar, we support adding anti-quotation to the generated quasi-quoters, which allows users of the defined language to mix concrete and abstract syntax almost seamlessly. Unlike previous methods of achieving anti-quotation, the method used by BNFC-meta is simple, efficient and avoids polluting the abstract syntax types.
我们提出了一种在Haskell中嵌入上下文无关语法的新方法,并从它们自动生成解析器和漂亮的打印机。我们已经在一个名为BNFC-meta的库中实现了这个方法(来自它所基于的BNF Converter)。该库使用元编程而不是传统的代码生成来构建编译器前端。解析器是由直接在Haskell模块中定义的带标签的BNF语法构建的。我们的解决方案结合了解析器生成器的特性(静态语法检查,高度专业化的语法DSL),并增加了一些组合库独有的特性,比如在Haskell中重用、参数化和生成语法的能力。为了允许用具体语法编写语法,BNFC-meta提供了一个准引号,它可以在编译时解析语法(嵌入在Haskell文件中),并使用元编程将其替换为抽象语法。我们还生成了准引号,这样我们用BNFC-meta定义的语言就可以以同样的方式嵌入。通过对语法的最小更改,我们支持在生成的准引号中添加反引号,这允许定义语言的用户几乎无缝地混合具体和抽象语法。与以往实现反引用的方法不同,BNFC-meta使用的方法简单、高效,避免了对抽象语法类型的污染。
{"title":"Embedded parser generators","authors":"Jonas Duregård, Patrik Jansson","doi":"10.1145/2034675.2034689","DOIUrl":"https://doi.org/10.1145/2034675.2034689","url":null,"abstract":"We present a novel method of embedding context-free grammars in Haskell, and to automatically generate parsers and pretty-printers from them. We have implemented this method in a library called BNFC-meta (from the BNF Converter, which it is built on). The library builds compiler front ends using metaprogramming instead of conventional code generation. Parsers are built from labelled BNF grammars that are defined directly in Haskell modules. Our solution combines features of parser generators (static grammar checks, a highly specialised grammar DSL) and adds several features that are otherwise exclusive to combinatory libraries such as the ability to reuse, parameterise and generate grammars inside Haskell.\u0000 To allow writing grammars in concrete syntax, BNFC-meta provides a quasi-quoter that can parse grammars (embedded in Haskell files) at compile time and use metaprogramming to replace them with their abstract syntax. We also generate quasi-quoters so that the languages we define with BNFC-meta can be embedded in the same way. With a minimal change to the grammar, we support adding anti-quotation to the generated quasi-quoters, which allows users of the defined language to mix concrete and abstract syntax almost seamlessly. Unlike previous methods of achieving anti-quotation, the method used by BNFC-meta is simple, efficient and avoids polluting the abstract syntax types.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"125 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2012-01-12","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"127406980","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}
引用次数: 18
Efficient parallel stencil convolution in Haskell 在Haskell中高效并行模板卷积
Pub Date : 2012-01-12 DOI: 10.1145/2034675.2034684
B. Lippmeier, G. Keller
Stencil convolution is a fundamental building block of many scientific and image processing algorithms. We present a declarative approach to writing such convolutions in Haskell that is both efficient at runtime and implicitly parallel. To achieve this we extend our prior work on the Repa array library with two new features: partitioned and cursored arrays. Combined with careful management of the interaction between GHC and its back-end code generator LLVM, we achieve performance comparable to the standard OpenCV library.
模板卷积是许多科学和图像处理算法的基本组成部分。我们提出了一种在Haskell中编写这种卷积的声明式方法,它在运行时既高效又隐式并行。为了实现这一点,我们用两个新特性扩展了我们之前在Repa数组库上的工作:分区数组和约束数组。结合对GHC及其后端代码生成器LLVM之间交互的精心管理,我们实现了与标准OpenCV库相当的性能。
{"title":"Efficient parallel stencil convolution in Haskell","authors":"B. Lippmeier, G. Keller","doi":"10.1145/2034675.2034684","DOIUrl":"https://doi.org/10.1145/2034675.2034684","url":null,"abstract":"Stencil convolution is a fundamental building block of many scientific and image processing algorithms. We present a declarative approach to writing such convolutions in Haskell that is both efficient at runtime and implicitly parallel. To achieve this we extend our prior work on the Repa array library with two new features: partitioned and cursored arrays. Combined with careful management of the interaction between GHC and its back-end code generator LLVM, we achieve performance comparable to the standard OpenCV library.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"21 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2012-01-12","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"130123300","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}
引用次数: 24
A library writer's guide to shortcut fusion 图书馆作者的快捷融合指南
Pub Date : 2012-01-12 DOI: 10.1145/2034675.2034682
T. Harper
There are now a variety of shortcut fusion techniques in the wild for removing intermediate data structures in Haskell. They are often presented, however, specialised to a specific data structure and interface. This can make it difficult to transfer these techniques to other settings. In this paper, we give a roadmap for a library writer who would like to implement fusion for his own library. We explain shortcut fusion without reference to any specific implementation by treating it as an instance of data refinement. We also provide an example application of our framework using the features available in the Glasgow Haskell Compiler.
现在有各种各样的快捷融合技术用于在Haskell中删除中间数据结构。然而,它们通常被专门用于特定的数据结构和接口。这使得将这些技术转移到其他设置变得困难。在本文中,我们为希望在自己的库中实现融合的库作者提供了一个路线图。我们解释快捷融合,而不参考任何具体实现,将其视为数据细化的一个实例。我们还提供了一个使用格拉斯哥Haskell编译器中可用特性的框架示例应用程序。
{"title":"A library writer's guide to shortcut fusion","authors":"T. Harper","doi":"10.1145/2034675.2034682","DOIUrl":"https://doi.org/10.1145/2034675.2034682","url":null,"abstract":"There are now a variety of shortcut fusion techniques in the wild for removing intermediate data structures in Haskell. They are often presented, however, specialised to a specific data structure and interface. This can make it difficult to transfer these techniques to other settings. In this paper, we give a roadmap for a library writer who would like to implement fusion for his own library. We explain shortcut fusion without reference to any specific implementation by treating it as an instance of data refinement. We also provide an example application of our framework using the features available in the Glasgow Haskell Compiler.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"55 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2012-01-12","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"121671313","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
Extending monads with pattern matching 使用模式匹配扩展单子
Pub Date : 2012-01-12 DOI: 10.1145/2034675.2034677
T. Petříček, A. Mycroft, Don Syme
Sequencing of effectful computations can be neatly captured using monads and elegantly written using do notation. In practice such monads often allow additional ways of composing computations, which have to be written explicitly using combinators. We identify joinads, an abstract notion of computation that is stronger than monads and captures many such ad-hoc extensions. In particular, joinads are monads with three additional operations: one of type m a -> m b -> m (a, b) captures various forms of parallel composition, one of type m a -> m a -> m a that is inspired by choice and one of type m a -> m (m a) that captures aliasing of computations. Algebraically, the first two operations form a near-semiring with commutative multiplication. We introduce docase notation that can be viewed as a monadic version of case. Joinad laws imply various syntactic equivalences of programs written using docase that are analogous to equivalences about case. Examples of joinads that benefit from the notation include speculative parallelism, waiting for a combination of user interface events, but also encoding of validation rules using the intersection of parsers.
有效计算的顺序可以使用单子整齐地捕获,并使用do表示法优雅地编写。在实践中,这样的单子通常允许以其他方式组合计算,这些计算必须使用组合子显式地编写。我们确定了连接点,这是一种抽象的计算概念,它比单子更强大,并捕获了许多这样的特别扩展。特别地,连接是带有三个附加操作的单子:一个是类型m a -> m b -> m (a, b),捕获各种形式的并行组合;一个是类型m a -> m a -> m a,受选择的启发;另一个是类型m a -> m (m a),捕获计算的混叠。在代数上,前两个运算与交换乘法形成近半环。我们引入的docase表示法可以看作是case的一元形式。连接定律意味着使用docase编写的程序的各种语法等价,类似于关于case的等价。受益于该符号的连接示例包括推测并行性,等待用户界面事件的组合,以及使用解析器的交集对验证规则进行编码。
{"title":"Extending monads with pattern matching","authors":"T. Petříček, A. Mycroft, Don Syme","doi":"10.1145/2034675.2034677","DOIUrl":"https://doi.org/10.1145/2034675.2034677","url":null,"abstract":"Sequencing of effectful computations can be neatly captured using monads and elegantly written using <b>do</b> notation. In practice such monads often allow additional ways of composing computations, which have to be written explicitly using combinators.\u0000 We identify joinads, an abstract notion of computation that is stronger than monads and captures many such ad-hoc extensions. In particular, joinads are monads with three additional operations: one of type <i>m</i> <i>a</i> -> <i>m</i> <i>b</i> -> <i>m</i> (<i>a</i>, <i>b</i>) captures various forms of parallel composition, one of type <i>m</i> <i>a</i> -> <i>m</i> <i>a</i> -> <i>m</i> <i>a</i> that is inspired by choice and one of type <i>m</i> <i>a</i> -> <i>m</i> (<i>m</i> a) that captures aliasing of computations. Algebraically, the first two operations form a near-semiring with commutative multiplication.\u0000 We introduce <b>docase</b> notation that can be viewed as a monadic version of <b>case</b>. Joinad laws imply various syntactic equivalences of programs written using <b>docase</b> that are analogous to equivalences about case. Examples of joinads that benefit from the notation include speculative parallelism, waiting for a combination of user interface events, but also encoding of validation rules using the intersection of parsers.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"36 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2012-01-12","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"128223331","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}
引用次数: 14
Termination combinators forever 永久终止组合子
Pub Date : 2012-01-12 DOI: 10.1145/2034675.2034680
Maximilian Bolingbroke, S. Jones, Dimitrios Vytiniotis
We describe a library-based approach to constructing termination tests suitable for controlling termination of symbolic methods such as partial evaluation, supercompilation and theorem proving. With our combinators, all termination tests are correct by construction. We show how the library can be designed to embody various optimisations of the termination tests, which the user of the library takes advantage of entirely transparently.
描述了一种基于库的终止测试方法,适用于控制部分求值、超编译和定理证明等符号方法的终止。使用我们的组合子,所有的终止测试都是正确的。我们展示了如何设计库来体现终止测试的各种优化,库的用户可以完全透明地利用这些优化。
{"title":"Termination combinators forever","authors":"Maximilian Bolingbroke, S. Jones, Dimitrios Vytiniotis","doi":"10.1145/2034675.2034680","DOIUrl":"https://doi.org/10.1145/2034675.2034680","url":null,"abstract":"We describe a library-based approach to constructing termination tests suitable for controlling termination of symbolic methods such as partial evaluation, supercompilation and theorem proving. With our combinators, all termination tests are correct by construction. We show how the library can be designed to embody various optimisations of the termination tests, which the user of the library takes advantage of entirely transparently.","PeriodicalId":188691,"journal":{"name":"ACM SIGPLAN Symposium/Workshop on Haskell","volume":"1 1","pages":"0"},"PeriodicalIF":0.0,"publicationDate":"2012-01-12","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":null,"resultStr":null,"platform":"Semanticscholar","paperid":"130589925","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}
引用次数: 9
期刊
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