Ghostbuster: a tool for simplifying and converting GADTs

T. L. McDonell, Timothy A. K. Zakian, M. Cimini, Ryan Newton
{"title":"Ghostbuster: a tool for simplifying and converting GADTs","authors":"T. L. McDonell, Timothy A. K. Zakian, M. Cimini, Ryan Newton","doi":"10.1145/2951913.2951914","DOIUrl":null,"url":null,"abstract":"Generalized Algebraic Dataypes, or simply GADTs, can encode non-trivial properties in the types of the constructors. Once such properties are encoded in a datatype, however, all code manipulating that datatype must provide proof that it maintains these properties in order to typecheck. In this paper, we take a step towards gradualizing these obligations. We introduce a tool, Ghostbuster, that produces simplified versions of GADTs which elide selected type parameters, thereby weakening the guarantees of the simplified datatype in exchange for reducing the obligations necessary to manipulate it. Like ornaments, these simplified datatypes preserve the recursive structure of the original, but unlike ornaments we focus on information-preserving bidirectional transformations. Ghostbuster generates type-safe conversion functions between the original and simplified datatypes, which we prove are the identity function when composed. We evaluate a prototype tool for Haskell against thousands of GADTs found on the Hackage package database, generating simpler Haskell'98 datatypes and round-trip conversion functions between the two.","PeriodicalId":336660,"journal":{"name":"Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming","volume":"16 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2016-09-04","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"5","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/2951913.2951914","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 5

Abstract

Generalized Algebraic Dataypes, or simply GADTs, can encode non-trivial properties in the types of the constructors. Once such properties are encoded in a datatype, however, all code manipulating that datatype must provide proof that it maintains these properties in order to typecheck. In this paper, we take a step towards gradualizing these obligations. We introduce a tool, Ghostbuster, that produces simplified versions of GADTs which elide selected type parameters, thereby weakening the guarantees of the simplified datatype in exchange for reducing the obligations necessary to manipulate it. Like ornaments, these simplified datatypes preserve the recursive structure of the original, but unlike ornaments we focus on information-preserving bidirectional transformations. Ghostbuster generates type-safe conversion functions between the original and simplified datatypes, which we prove are the identity function when composed. We evaluate a prototype tool for Haskell against thousands of GADTs found on the Hackage package database, generating simpler Haskell'98 datatypes and round-trip conversion functions between the two.
Ghostbuster:一个简化和转换gadt的工具
广义代数数据类型(简称gadt)可以在构造函数的类型中编码重要属性。但是,一旦将这些属性编码到数据类型中,所有操作该数据类型的代码必须提供它维护这些属性的证据,以便进行类型检查。在本文中,我们朝着逐步实现这些义务迈出了一步。我们引入了一个工具Ghostbuster,它可以生成gadt的简化版本,其中省略了选定的类型参数,从而削弱了简化数据类型的保证,以减少操作它所必需的义务。与装饰品一样,这些简化的数据类型保留了原始的递归结构,但与装饰品不同的是,我们关注的是保持信息的双向转换。Ghostbuster生成了原始数据类型和简化数据类型之间的类型安全转换函数,我们证明了这些函数在组成时是恒等函数。我们根据在Hackage包数据库中找到的数千个gadt来评估Haskell的原型工具,生成更简单的Haskell'98数据类型和两者之间的往返转换函数。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术官方微信