Transporting functions across ornaments
Dagand, Pierre-Évariste and McBride, Conor (2014) Transporting functions across ornaments. Journal of Functional Programming, 24 (2-3). pp. 316-383. ISSN 0956-7968 (https://doi.org/10.1017/S0956796814000069)
Preview |
Text.
Filename: Dagand_McBride_JFP_2014_Transporting_functions_across_ornaments.pdf
Accepted Author Manuscript Download (470kB)| Preview |
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 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.
ORCID iDs
Dagand, Pierre-Évariste and McBride, Conor ORCID: https://orcid.org/0000-0003-1487-0886;-
-
Item type: Article ID code: 51789 Dates: DateEvent30 May 2014Published23 April 2014Published OnlineSubjects: Science > Mathematics > Computer software Department: Faculty of Science > Computer and Information Sciences Depositing user: Pure Administrator Date deposited: 19 Feb 2015 13:05 Last modified: 02 Dec 2024 06:30 Related URLs: URI: https://strathprints.strath.ac.uk/id/eprint/51789