Types that Change: The Extensible Type Design Pattern

Ivan Perez
{"title":"Types that Change: The Extensible Type Design Pattern","authors":"Ivan Perez","doi":"10.1145/3609025.3609475","DOIUrl":null,"url":null,"abstract":"Compilers are often structured as chains of transformations, from source code to object code, through multiple intermediate representations. The existence of different representations of the same program presents challenges both for code maintenance and in terms of architecture. The types used to capture programs at multiple stages may be similar but not interchangeable, leading to code duplication. Methods to alleviate such duplication often lead to violations of software engineering principles of abstraction and encapsulation. This pearl discusses a design pattern where an algebraic data type (ADT) is extended with an argument type function that is applied to every component of the ADT. The resulting parametric type can be instantiated with multiple type functions, each providing a different feature. We demonstrate the versatility of this pattern by capturing notions of traceability and error recovery, and demonstrate that it can also be used to selectively modify existing types, as well as to extend them. Our proposal has been validated by applying it to a real-world use case with very good results.","PeriodicalId":109131,"journal":{"name":"Proceedings of the 1st ACM SIGPLAN International Workshop on Functional Software Architecture","volume":"169 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2023-08-30","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the 1st ACM SIGPLAN International Workshop on Functional Software Architecture","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/3609025.3609475","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0

Abstract

Compilers are often structured as chains of transformations, from source code to object code, through multiple intermediate representations. The existence of different representations of the same program presents challenges both for code maintenance and in terms of architecture. The types used to capture programs at multiple stages may be similar but not interchangeable, leading to code duplication. Methods to alleviate such duplication often lead to violations of software engineering principles of abstraction and encapsulation. This pearl discusses a design pattern where an algebraic data type (ADT) is extended with an argument type function that is applied to every component of the ADT. The resulting parametric type can be instantiated with multiple type functions, each providing a different feature. We demonstrate the versatility of this pattern by capturing notions of traceability and error recovery, and demonstrate that it can also be used to selectively modify existing types, as well as to extend them. Our proposal has been validated by applying it to a real-world use case with very good results.
可更改的类型:可扩展类型设计模式
编译器通常结构为转换链,从源代码到目标代码,通过多个中间表示。同一程序的不同表示形式的存在对代码维护和体系结构都提出了挑战。用于在多个阶段捕获程序的类型可能相似但不可互换,从而导致代码重复。减轻这种重复的方法通常会导致违反软件工程的抽象和封装原则。本文讨论了一种设计模式,其中代数数据类型(ADT)通过应用于ADT的每个组件的参数类型函数进行扩展。产生的参数类型可以用多个类型函数实例化,每个函数提供不同的特性。我们通过捕获可跟踪性和错误恢复的概念来演示此模式的多功能性,并演示它还可以用于有选择地修改现有类型,以及扩展它们。我们的建议已经通过将其应用到一个真实的用例中得到了验证,结果非常好。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约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学术官方微信