Abstract
Dependently typed languages are well known for having a problem with code reuse. Traditional non-indexed algebraic datatypes (e.g. lists) appear alongside a plethora of indexed variations (e.g. vectors). Functions are often rewritten for both non-indexed and indexed versions of essentially the same datatype, which is a source of code duplication.
We work in a Curry-style dependent type theory, where the same untyped term may be classified as both the non-indexed and indexed versions of a datatype. Many solutions have been proposed for the problem of dependently typed reuse, but we exploit Curry-style type theory in our solution to not only reuse data and programs, but do so at zero-cost (without a runtime penalty). Our work is an exercise in dependently typed generic programming, and internalizes the process of zero-cost reuse as the identity function in a Curry-style theory.
Supplemental Material
- Bruno Barras and Bruno Bernardo. 2008. The implicit calculus of constructions as a programming language with dependent types. Foundations of Software Science and Computational Structures (2008), 365–379. Google Scholar
Digital Library
- Jean-Philippe Bernardy and Moulin Guilhem. 2013. Type-theory in Color. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming (ICFP ’13). ACM, New York, NY, USA, 61–72. Google Scholar
Digital Library
- Edwin Brady. 2013. Idris, a general-purpose dependently typed programming language: Design and implementation. Journal of Functional Programming 23, 05 (2013), 552–593.Google Scholar
Cross Ref
- Joachim Breitner, Richard A. Eisenberg, Simon Peyton Jones, and Stephanie Weirich. 2016. Safe zero-cost coercions for Haskell. J. Funct. Program. 26 (2016), e15.Google Scholar
Cross Ref
- Pierre-Evariste Dagand and Conor McBride. 2012. Transporting Functions Across Ornaments. In Proceedings of the 17th ACM SIGPLAN International Conference on Functional Programming (ICFP ’12). ACM, New York, NY, USA, 103–114. Google Scholar
Digital Library
- Pierre-Evariste Dagand, Nicolas Tabareau, and Éric Tanter. 2016. Partial Type Equivalences for Verified Dependent Interoperability. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming (ICFP 2016). ACM, New York, NY, USA, 298–310. Google Scholar
Digital Library
- Pierre-Evariste Dagand, Nicolas Tabareau, and Éric Tanter. 2018. Foundations of dependent interoperability. Journal of Functional Programming 28 (2018).Google Scholar
- Leonardo de Moura, Soonho Kong, Jeremy Avigad, Floris Van Doorn, and Jakob von Raumer. 2015. The Lean theorem prover (system description). In International Conference on Automated Deduction. Springer, 378–388.Google Scholar
Cross Ref
- Larry Diehl and Aaron Stump. 2018. Zero-Cost Coercions for Program and Proof Reuse. (2018). arXiv: 1802.00787Google Scholar
- Denis Firsov, Richard Blair, and Aaron Stump. 2018. Efficient Mendler-Style Lambda-Encodings in Cedille. In Interactive Theorem Proving - 9th International Conference, ITP 2018, Held as Part of the Federated Logic Conference, FloC 2018, Oxford, UK, July 9-12, 2018, Proceedings. 235–252.Google Scholar
- Denis Firsov and Aaron Stump. 2018. Generic Derivation of Induction for Impredicative Encodings in Cedille. In Certified Programs and Proofs (CPP), June Andronick and Amy Felty (Eds.). Google Scholar
Digital Library
- Matthew Flatt and PLT. 2010. Reference: Racket. Technical Report PLT-TR-2010-1. PLT Design Inc. https://racket-lang.org/tr1/ .Google Scholar
- Herman Geuvers. 2001. Induction Is Not Derivable in Second Order Dependent Type Theory. In Typed Lambda Calculi and Applications (TLCA). 166–181. Google Scholar
Digital Library
- Hsiang-Shang Ko and Jeremy Gibbons. 2013. Relational algebraic ornaments. In Proceedings of the 2013 ACM SIGPLAN workshop on Dependently-typed programming. ACM, 37–48. Google Scholar
Digital Library
- Alexei Kopylov. 2003. Dependent Intersection: A New Way of Defining Records in Type Theory. In 18th IEEE Symposium on Logic in Computer Science (LICS). 86–95. Google Scholar
Digital Library
- Conor McBride. 2011. Ornamental algebras, algebraic ornaments. (2011).Google Scholar
- Conor McBride and James McKinna. 2004. The view from the left. Journal of functional programming 14, 1 (2004), 69–111. Google Scholar
Digital Library
- Alexandre Miquel. 2001. The Implicit Calculus of Constructions Extending Pure Type Systems with an Intersection Type Binder and Subtyping. In Typed Lambda Calculi and Applications (TLCA), Samson Abramsky (Ed.). 344–359. Google Scholar
Digital Library
- Ulf Norell. 2007. Towards a practical programming language based on dependent type theory. Ph.D. Dissertation. Chalmers University of Technology.Google Scholar
- Ulf Norell. 2008. Dependently typed programming in Agda. In International School on Advanced Functional Programming. Springer, 230–266. Google Scholar
Digital Library
- Aaron Stump. 2017. The calculus of dependent lambda eliminations. J. Funct. Program. 27 (2017), e14.Google Scholar
Cross Ref
- Aaron Stump. 2018a. From Realizability to Induction via Dependent Intersection. Ann. Pure Appl. Logic (2018). to appear.Google Scholar
- Aaron Stump. 2018b. Syntax and Semantics of Cedille. (2018). arXiv: 1806.04709Google Scholar
- The Coq Development Team. 2008. The Coq Proof Assistant Reference Manual. http://coq.inria.frGoogle Scholar
- J. B. Wells. 1999. Typability and Type Checking in System F are Equivalent and Undecidable. Ann. Pure Appl. Logic 98, 1-3 (1999), 111–156.Google Scholar
Cross Ref
Index Terms
Generic zero-cost reuse for dependent types
Recommendations
Leveling up dependent types: generic programming over a predicative hierarchy of universes
DTP '13: Proceedings of the 2013 ACM SIGPLAN workshop on Dependently-typed programmingGeneric programming is about writing a single function that does something different for each type. In most languages one cannot case over the structure of types. So in such languages generic programming is accomplished by defining a universe, a data ...
Zero-Cost Constructor Subtyping
IFL '20: Proceedings of the 32nd Symposium on Implementation and Application of Functional LanguagesConstructor subtyping is a form of subtyping where two inductive types can be related as long as the inductive signature of one is a subsignature of the other. To be a subsignature requires every constructor of the smaller datatype be present in the ...
Generic constructors and eliminators from descriptions: type theory as a dependently typed internal DSL
WGP '14: Proceedings of the 10th ACM SIGPLAN workshop on Generic programmingDependently typed languages with an "open" type theory introduce new datatypes using an axiomatic approach. Each new datatype introduces axioms for constructing values of the datatype, and an elimination axiom (which we call the standard eliminator) for ...






Comments