ABSTRACT
We present an approach to enriching the type system of ML with a restricted form of dependent types, where type index objects are drawn from a constraint domain C, leading to the DML(C) language schema. This allows specification and inference of significantly more precise type information, facilitating program error detection and compiler optimization. A major complication resulting from introducing dependent types is that pure type inference for the enriched system is no longer possible, but we show that type-checking a sufficiently annotated program in DML(C) can be reduced to constraint satisfaction in the constraint domain C. We exhibit the unobtrusiveness of our approach through practical examples and prove that DML(C) is conservative over ML. The main contribution of the paper lies in our language design, including the formulation of type-checking rules which makes the approach practical. To our knowledge, no previous type system for a general purpose programming language such as ML has combined dependent types with features including datatype declarations, higher-order functions, general recursions, let-polymorphism, mutable references, and exceptions. In addition, we have finished a prototype implementation of DML(C) for an integer constraint domain C, where constraints are linear inequalities (Xi and Pfenning 1998).
- Augustsson, L. (1998). Cayenne - a language with dependent types. In Proceedings of A CM SIGPLAN International Conference on Functional Programming, pp. 239-250.]] Google ScholarDigital Library
- Constable, It. L. et al. (1986). Implementing Mathematics with the Nuprl Proof Development System. Englewood Cliffs, New Jersey: Prentice-Hall.]] Google ScholarDigital Library
- Danvy, O. (1998, May). Functional unparsing. Technical Report RS-98-12, University of Aarhus.]]Google Scholar
- Dowek, G., A. Felty, H. Herbelin, G. Huet, C. Murthy, C. Parent, C. Paulin-Mohring, and B. Werner (1993). The Coq proof assistant user's guide. Rapport Techniques 154, IN- RIA, Rocquencourt, France. Version 5.8.]]Google Scholar
- Freeman, T. and F. Pfenning (1991). Refinement types for ML. In A CM SIGPLAN Conference on Programming Language Design and Implementation, Toronto, Ontario, pp. 268- 277.]] Google ScholarDigital Library
- Harper, It. W., F. Honsell, and G. D. Plotkin (1993, January). A framework for defining logics. Journal o/the A CM ~ 0 (1), 143-184.]] Google ScholarDigital Library
- Hayashi, S. and H. Nakano (1988). PX: A Computational Logic. The MIT Press.]] Google ScholarDigital Library
- Hudak, P., S. L. Peyton Jones, and P. Wadler (1992, May). Report on the programming language Haskell, a non-strict purely-functional programming language, Version 1.2. SIG- PLAN Notices ~7(5).]] Google ScholarDigital Library
- Hughes, J., L. Pareto, and A. Sabry (1996). Proving the correctness of reactive systems using sized types. In Conference Record o/P3rd A CM SIGPLAN-SIGA CT Symposium on Principles of Programming Languages, pp. 410-423.]] Google ScholarDigital Library
- Jay, C. and M. Sekanina (1996). Shape checking of array programs. Technical Report 96.09, University of Technology, Sydney, Australia.]]Google Scholar
- Kreitz, C., M. Hayden, and J. Hickey (1998, July). A proof environment for the development of group communication systems. In H. Kirchner and C. Kirchner (Eds.), 15th International Conference on Automated Deduction, LNAI 1421, Lindau, Germany, pp. 317-332. Springer-Verlag.]] Google ScholarDigital Library
- Milner, R., M. Tofte, and R. W. Harper (1990). The Definition o.f Standard ML. Cambridge, Massachusetts: MIT Press.]] Google ScholarDigital Library
- Moggi, E. (1989). Computational lambda-calculus and monads. In Proceedings Fourth Annual Symposium on Logic in Computer Science, pp. 14-23.]] Google ScholarDigital Library
- Necula, G. (1997). Proof-carrying code. In Conference Record of 2~th Annual A CM Symposium on Principles of Programming Languages, pp. 106-119. ACM press.]] Google ScholarDigital Library
- Necula, G. and P. Lee (1998, June). The design and implementation of a certifying compiler. In A CM SIGPLAN '98 Conference on Programming Language Design and Implementation, pp. 333-344. ACM press.]] Google ScholarDigital Library
- Owre, S., S. Rajan, J. Rushby, N. Shankar, and M. Srivas (1996, July/August). PVS: Combining specification, proof checking, and model checking. In R. Alur and T. A. Henzinger (Eds.), Proceedings o.f the 8th International Conference on Computer-Aided Verification, CA V '96, New Brunswick, NJ, pp. 411-414. Springer-Verlag LNCS 1102.]] Google ScholarDigital Library
- Parent, C. (1995). Synthesizing proofs from programs in the calculus of inductive constructions. In Proceedings o/the International Conference on Mathematics for Programs Constructions. Springer-Verlag LNCS 947.]] Google ScholarDigital Library
- Pierce, B. and D. Turner (1998). Local type inference. In Proceedings o~ the 25th Annual A CM SIGPLAN-SIGA CT Symposium on Principles o.f Programming Languages, pp. 252-265.]] Google ScholarDigital Library
- Sabry, A. and M. Felleisen (1993). Reasoning about programs in continuation-passing style. LISP and Symbolic Computation 6(3/4), 289-360.]] Google ScholarDigital Library
- Sannella, D. and A. Tarlecki (1989, February). Toward formal development of ML programs: Foundations and methodology. Technical Report ECS-LFCS-89-71, Laboratory for Foundations of Computer Science, Depatment of Computer Science, University of Edinburgh.]]Google Scholar
- Sulzmann, M., M. Odersky, and M. Wehr (1997). Type inference with constrained types. In Proceedings of 4th International Workshop on Foundations o~ Object-Oriented Languages.]]Google Scholar
- Weis, P. and X. Leroy (1993). Le langage Carol. Paris: InterEditions.]]Google Scholar
- Xi, H. (1997, November). Some examples of DML programming. Available at ht tp : //www. cs. cmu. edu/'hwxi/DbIL/oxamplos 1.]]Google Scholar
- H. (1998). Dependent Types in Practical Programming. Ph. D. thesis, Carnegie Mellon University. pp. viii+189. Forthcoming. The current version is available as http : //www. ~ s. cmu. edu/" hwxi/DML/thes is. ps.]]Google Scholar
- Xi, H. (1999, January). Dead code elimination through dependent types. In The First International Workshop on Practical Aspects of Declarative Languages, San Antonio, Texas. To appear.]] Google ScholarDigital Library
- Xi, H. and F. Pfenning (1998, June). Eliminating array bound checking through dependent types. In Proceedings of A CM SIGPLAN Conference on Programming Language Design and Implementation, pp. 249-257.]] Google ScholarDigital Library
- Zenger, C. (1997). indexed types. Theoretical Computer Science 187, 147-165.]] Google ScholarDigital Library
- Zenger, C. (1998). Indizierte Typen. Ph. D. thesis, Fakultgt fiir Informatik, Universitgt Karlsruhe. Forthcoming.]]Google Scholar
Index Terms
- Dependent types in practical programming
Recommendations
Cayenne—a language with dependent types
Cayenne is a Haskell-like language. The main difference between Haskell and Cayenne is that Cayenne has dependent types, i.e., the result type of a function may depend on the argument value, and types of record components (which can be types or values) ...
Interactive programming with dependent types
ICFP '13: Proceedings of the 18th ACM SIGPLAN international conference on Functional programmingIn dependently typed languages run-time values can appear in types, making it possible to give programs more precise types than in languages without dependent types. This can range from keeping track of simple invariants like the length of a list, to ...
Comments