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.
- R. Atkey, P. Johann, and N. Ghani. When is a type refinement an inductive type? In phFOSSACS, volume 6604 of phLecture Notes in Computer Science, pages 72--87. Springer, 2011. Google Scholar
Digital Library
- J.-P. Bernardy and M. Lasson. Realizability and parametricity in pure type systems. In phFOSSACS, volume 6604 of phLecture Notes in Computer Science, pages 108--122. Springer, 2011. Google Scholar
Digital Library
- R. S. Bird and O. de Moor. phAlgebra of programming. Prentice Hall, 1997. Google Scholar
Digital Library
- E. Brady, C. McBride, and J. McKinna. Inductive families need not store their indices. In phTypes for Proofs and Programs, pages 115--129. 2004.Google Scholar
- J. Chapman, P.-E. Dagand, C. McBride, and P. Morris. The gentle art of levitation. phSIGPLAN Not., 45: 3--14, September 2010. Google Scholar
Digital Library
- T. Coquand. Pattern matching with dependent types. In phTypes for Proofs and Programs, 1992.Google Scholar
- P. Dybjer. Inductive families. phFormal Asp. Comput., 6 (4): 440--465, 1994.Google Scholar
Digital Library
- T. Freeman and F. Pfenning. Refinement types for ML. phSIGPLAN Not., 26: 268--277, May 1991. Google Scholar
Digital Library
- C. Fumex, N. Ghani, and P. Johann. Indexed induction and coinduction, fibrationally. In phCALCO, pages 176--191, 2011. Google Scholar
Digital Library
- R. Harper and C. Stone. A Type-Theoretic interpretation of standard ML. In phProof, Language, and Interaction: essays in honour of Robin Milner, 2000. Google Scholar
Digital Library
- H.-S. Ko and J. Gibbons. Modularising inductive families. In phWorkshop on Generic Programming, pages 13--24, 2011. Google Scholar
Digital Library
- C. McBride. Ornamental algebras, algebraic ornaments. phJournal of Functional Programming, to appear, 2012.Google Scholar
- C. McBride and J. McKinna. The view from the left. phJ. Funct. Program., 14 (1): 69--111, 2004. Google Scholar
Digital Library
- C. McBride, H. Goguen, and J. McKinna. A few constructions on constructors. In phTYPES, pages 186--200, 2004. Google Scholar
Digital Library
- P. Morris, T. Altenkirch, and N. Ghani. A universe of strictly positive families. phInt. J. Found. Comput. Sci., 20 (1): 83--107, 2009.Google Scholar
Cross Ref
- U. Norell. phTowards a practical programming language based on dependent type theory. PhD thesis, Chalmers University of Technology, 2007.Google Scholar
- P.-Y. Strub. Coq modulo theory. In phCSL, pages 529--543, 2010. Google Scholar
Digital Library
- N. Swamy, J. Chen, C. Fournet, P.-Y. Strub, K. Bhargavan, and J. Yang. Secure distributed programming with value-dependent types. In phICFP, pages 266--278. ACM, 2011. Google Scholar
Digital Library
- }coq:manualThe Coq Development Team. phThe Coq Proof Assistant Reference Manual.Google Scholar
- H. Xi, C. Chen, and G. Chen. Guarded recursive datatype constructors. In phPOPL, 2003. Google Scholar
Digital Library
Index Terms
Transporting functions across ornaments
Recommendations
Ornaments in practice
WGP '14: Proceedings of the 10th ACM SIGPLAN workshop on Generic programmingOrnaments have been introduced as a way to describe some changes in datatype definitions that preserve their recursive structure, reorganizing, adding, or dropping some pieces of data. After a new data structure has been described as an ornament of ...
Transporting functions across ornaments
ICFP '12: Proceedings of the 17th ACM SIGPLAN international conference on Functional programmingProgramming 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 ...
Unifying typing and subtyping
In recent years dependent types have become a hot topic in programming language research. A key reason why dependent types are interesting is that they allow unifying types and terms, which enables both additional expressiveness and economy of concepts. ...







Comments