Transporting functions across ornaments

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 article, 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 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.
Type de document :
Article dans une revue
Journal of Functional Programming, Cambridge University Press (CUP), 2014, 24 (2-3), pp.67. 〈10.1017/S0956796814000069〉
Liste complète des métadonnées

Littérature citée [31 références]  Voir  Masquer  Télécharger
Contributeur : Pierre-Évariste Dagand <>
Soumis le : samedi 28 décembre 2013 - 14:49:40
Dernière modification le : vendredi 25 mai 2018 - 12:02:07
Document(s) archivé(s) le : vendredi 28 mars 2014 - 22:05:52


Fichiers produits par l'(les) auteur(s)




Pierre-Évariste  Dagand, Conor  Mcbride. Transporting functions across ornaments. Journal of Functional Programming, Cambridge University Press (CUP), 2014, 24 (2-3), pp.67. 〈10.1017/S0956796814000069〉. 〈hal-00922581〉



Consultations de la notice


Téléchargements de fichiers