Skip to main content Accessibility help
×
Home

Transporting functions across ornaments

  • PIERRE-ÉVARISTE DAGAND (a1) and CONOR McBRIDE (a2)

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.

Copyright

References

Hide All
Atkey, R., Johann, P & Ghani, N. (2012) Refining inductive types. Logic. Methods Comput. Sci. 8 (2), 9. 10.2168/LMCS-8(2:9)2012.
Benton, N., Hur, C.-K., Kennedy, A. J. & Mcbride, C. (2012) Strongly typed term representations in coq. J. Autom. Reason. 49 (2), 141159. 10.1007/s10817-011-9219-0.
Bernardy, J.-P. & Guilhem, M. (2013) Type-theory in color. In Proceedings of the International Conference on Functional Programming, pp. 6172. 10.1145/2500365.2500577.
Bernardy, J.-P. & Lasson, M. (2011) Realizability and parametricity in pure type systems. Foundations of Software Science and Computation Structures, Lecture Notes in Computer Science, vol. 6604. Berlin, Germany: Springer, pp. 108122. 10.1007/978-3-642-19805-28.
Bird, R. S. & de Moor, O. (1997). Algebra of Programming. Upper Saddle River, NJ: Prentice Hall.
Brady, E. & Hammond, K. (2010). Scrapping your inefficient engine: Using partial evaluation to improve domain-specific language implementation. In International Conference in Functional Programming, pp. 297308. 10.1145/1863543.1863587.
Brady, E., McBride, C. & McKinna, J. (2003) Inductive families need not store their indices. Types for Proofs and Programs. Berlin, Germany: Springer. 10.1007/978-3-540-24849-18.
Chapman, J., Dagand, P.-É., McBride, C., & Morris, P. (2010). The gentle art of levitation. In International Conference on Functional Programming, pp. 314. 10.1145/1863543.1863547.
Cheney, J. & Hinze, R. (2003) First-Class Phantom Types. Technical Report. Cornell University, Ithaca, NY.
Dagand, P.-E. (2013) Reusability and Dependent Types. PhD thesis, University of Strathclyde, Glasgow, UK.
Dagand, P.-E. & McBride, C. (2012) Transporting functions across ornaments. In Proceedings of the 17th International Conference on Func tional Programming (ICFP 2012), pp. 103114. 10.1145/2364527.2364544.
Dagand, P.-E. & McBride, C. (2013a) A categorical treatment of ornaments. In Twenty-Eighth Annual ACM/IEEE Symposium on Logics in Computer Science (LICS 2013). 10.1109/LICS.2013.60.
Dagand, P.-E. & McBride, C. (2013b) Elaborating inductive definitions. Journées francophones des langages applicatifs. Available at: http://hal.inria.fr/hal-00778975.
Dybjer, P. (1994) Inductive families. Form. Asp. Comput. 6 (4), 440465. 10.1007/BF01211308.
Freeman, T. & Pfenning, F. (1991) Refinement types for ML. In Programming Language Design and Implementation, pp. 268277. 10.1145/113445.113468.
Fumex, C. (2012) Induction and Coinduction Schemes in Category Theory. PhD thesis, University of Strathclyde, Glasgow, UK.
Gonthier, G., Mahboubi, A. & Tassi, E. (2008) A Small Scale Reflection Extension for the Coq System. Research Report RR-6455. Valbonne, France: INRIA.
Hermida, C. & Jacobs, B. (1998) Structural induction and coinduction in a fibrational setting. Inf. Computat. 145 (2), 107152. 10.1006/inco.1998.2725.
Hofmann, M. & Streicher, T. (1994) The groupoid model refutes uniqueness of identity proofs. Proceedings of the Symposium on Logic in Computer Science, pp. 208212. 10.1109/LICS.1994.316071.
Ko, H.-S. & Gibbons, J. (2011) Modularising inductive families. Workshop on Generic Programming. ACM, pp. 1324.
Lindblad, F. & Benke, M. (2004) A tool for automated theorem proving in Agda. In Types for Proofs and Programs. Berlin, Germany: Springer, pp. 154169. 10.1007/1161799010.
McBride, C. (1999). Dependently Typed Functional Programs and Their Proofs. PhD thesis, LFCS, University of Edinburgh, Edinburgh, UK.
McBride, C. (2002). Elimination with a motive. In Types for Proofs and Programs. Berlin, Germany: Springer, 197216. 10.1007/3-540-45842-513.
McBride, C. (to appear). Ornamental algebras, algebraic ornaments. J. Funct. Program.
McBride, C., Goguen, H. & McKinna, J. (2004) A few constructions on constructors. Proceedings of International Workshop, Types for Proofs and Programs (TYPES 2004), pp. 18620010.1007/1161799012.
McBride, C. & McKinna, J. (2004). The view from the left. J. Funct. Program. 14 (1), 69111. 10.1007/1178027427.
Morris, P., Altenkirch, T. & Ghani, N. (2009) A universe of strictly positive families. Int. J. Found. Comput. Sci. 20 (1), 83107. 10.1142/S0129054109006462.
Paulin-Mohring, C. (1989) Extraction de Programmes dans le Calcul des Constructions. PhD thesis, Université Paris VII, France.
Schrijvers, T., Peyton Jones, S., Sulzmann, M. & Vytiniotis, D. (2009) Complete and decidable type inference for GADTs. In Proceedings of International Conference on Functional Programming, pp. 341352. 10.1145/1596550.1596599.
Strub, P.-Y. (2010) Coq modulo theory. Comput. Sci. Logic. pp. 529543. 10.1007/978-3-642-15205-440.
Swamy, N., Chen, J., Fournet, C., Strub, P.-Y., Bhargavan, K. & Yang, J. (2011) Secure distributed programming with value-dependent types. In Proceedings of International Conference on Functional Programming, pp. 266278. 10.1145/2034773.2034811.
Wadler, P. (1989) Theorems for free! In Proceedings of Conference on Functional Programming Languages and Computer Architecture, pp. 347359. 10.1145/99370.99404.

Transporting functions across ornaments

  • PIERRE-ÉVARISTE DAGAND (a1) and CONOR McBRIDE (a2)

Metrics

Altmetric attention score

Full text views

Total number of HTML views: 0
Total number of PDF views: 0 *
Loading metrics...

Abstract views

Total abstract views: 0 *
Loading metrics...

* Views captured on Cambridge Core between <date>. This data will be updated every 24 hours.

Usage data cannot currently be displayed.

Transporting functions across ornaments

  • PIERRE-ÉVARISTE DAGAND (a1) and CONOR McBRIDE (a2)
Submit a response

Discussions

No Discussions have been published for this article.

×

Reply to: Submit a response


Your details


Conflicting interests

Do you have any conflicting interests? *