Author:
DAGAND PIERRE-ÉVARISTE,McBRIDE CONOR
Abstract
AbstractProgramming 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 attempt to reuse code across similarly structured data. In this paper, we capitalise on the structural invariants of datatypes. To do so, we first adapt 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 users can ask the definition of addition to be lifted to lists and they will only be asked the details necessary to carry on adding lists rather than numbers. Our presentation is formalised in the 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
Cambridge University Press (CUP)
Reference32 articles.
1. The groupoid model refutes uniqueness of identity proofs;Hofmann;Proceedings of the Symposium on Logic in Computer Science,1994
Cited by
10 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Merging Inductive Relations;Proceedings of the ACM on Programming Languages;2023-06-06
2. Intrinsically-typed definitional interpreters à la carte;Proceedings of the ACM on Programming Languages;2022-10-31
3. Datatype-generic programming meets elaborator reflection;Proceedings of the ACM on Programming Languages;2022-08-29
4. LibNDT: Towards a Formal Library on Spreadable Properties over Linked Nested Datatypes;Electronic Proceedings in Theoretical Computer Science;2022-06-30
5. A simpler encoding of indexed types;Proceedings of the 6th ACM SIGPLAN International Workshop on Type-Driven Development;2021-08-18