Affiliation:
1. University of Strathclyde, Glasgow, United Kingdom
Abstract
Programming with dependent types is a blessing and a curse. It is a blessing to be able to bake invariants into the definition of datatypes: we can finally write correct-by-construction software. However, this extreme accuracy is also a curse: a datatype is the combination of a structuring medium together with a special purpose logic. These domain-specific logics hamper any effort of code reuse among similarly structured data. In this paper, we exorcise our datatypes by adapting the notion of ornament to our universe of inductive families. We then show how code reuse can be achieved by ornamenting functions. Using these functional ornaments, we capture the relationship between functions such as the addition of natural numbers and the concatenation of lists. With this knowledge, we demonstrate how the implementation of the former informs the implementation of the latter: the user can ask the definition of addition to be lifted to lists and she will only be asked the details necessary to carry on adding lists rather than numbers. Our presentation is formalised in a type theory with a universe of datatypes and all our constructions have been implemented as generic programs, requiring no extension to the type theory.
Publisher
Association for Computing Machinery (ACM)
Subject
Computer Graphics and Computer-Aided Design,Software
Cited by
14 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Focusing on Refinement Typing;ACM Transactions on Programming Languages and Systems;2023-12-20
2. A completely unique account of enumeration;Proceedings of the ACM on Programming Languages;2022-08-29
3. Deferring the details and deriving programs;Proceedings of the 4th ACM SIGPLAN International Workshop on Type-Driven Development - TyDe 2019;2019
4. Generic zero-cost reuse for dependent types;Proceedings of the ACM on Programming Languages;2018-07-30
5. Ghostbuster: A tool for simplifying and converting GADTs;Journal of Functional Programming;2018