Abstract
We study HMG(X), an extension of the constraint-based type system HM(X) with deep pattern matching, polymorphic recursion, and guarded algebraic data types. Guarded algebraic data types subsume the concepts known in the literature as indexed types, guarded recursive datatype constructors, (first-class) phantom types, and equality qualified types, and are closely related to inductive types. Their characteristic property is to allow every branch of a case construct to be typechecked under different assumptions about the type variables in scope. We prove that HMG(X) is sound and that, provided recursive definitions carry a type annotation, type inference can be reduced to constraint solving. Constraint solving is decidable, at least for some instances of X, but prohibitively expensive. Effective type inference for guarded algebraic data types is left as an issue for future research.
Supplemental Material
Available for Download
Online appendix to designing mediation for context-aware applications. The appendix supports the information on page 1.
- Aiken, A. S. and Wimmers, E. L. 1993. Type inclusion constraints and type inference. In Proceedings of the Conference on Functional Programming Languages and Computer Architecture (FPCA). ACM Press, 31--41.]] Google ScholarDigital Library
- Bird, R. and Meertens, L. 1998. Nested datatypes. In Proceedings of the International Conference on Mathematics of Program Construction (MPC). Lecture Notes in Computer Science, vol. 1422. Springer Verlag, 52--67.]] Google ScholarDigital Library
- Cheney, J. and Hinze, R. 2002. A lightweight implementation of generics and dynamics. In Proceedings of the Haskell Workshop.]] Google ScholarDigital Library
- Cheney, J. and Hinze, R. 2003. First-Class phantom types. Tech. Rep. 1901, Cornell University.]]Google Scholar
- Comon, H. and Lescanne, P. 1989. Equational problems and disunification. J. Symb. Comput. 7, 371--425.]] Google ScholarDigital Library
- Crary, K., Weirich, S., and Morrisett, G. 2002. Intensional polymorphism in type erasure semantics. J. Functional Program. 12, 6 (Nov.), 567--600.]] Google ScholarDigital Library
- Curtis, P. 1990. Constrained quantification in polymorphic type analysis. Ph.D. thesis, Cornell University.]] Google ScholarDigital Library
- Freeman, T. and Pfenning, F. 1991. Refinement types for ML. In Proceedings of the ACM Conference on Programming Language Design and Implementation (PLDI). 268--277.]] Google ScholarDigital Library
- Hanus, M. 1988. Horn clause specifications with polymorphic types. Ph.D. thesis, Fachbereich Informatik, Universität Dortmund.]]Google Scholar
- Hanus, M. 1989. Horn clause programs with polymorphic types: Semantics and resolution. In Proceedings of the International Joint Conference on Theory and Practice of Software Development (TAPSOFT). Lecture Notes in Computer Science, vol. 352. Springer Verlag, 225--240.]] Google ScholarDigital Library
- Henglein, F. 1993. Type inference with polymorphic recursion. ACM Trans. Program. Lang. Syst. 15, 2 (Apr.), 253--289.]] Google ScholarDigital Library
- Hindley, J. R. 1969. The principal type-scheme of an object in combinatory logic. Trans. Am. Math. Soc. 146, 29--60.]]Google Scholar
- Hinze, R. 2003. Fun with phantom types. In The Fun of Programming, J. Gibbons and O. de Moor, Eds. Palgrave Macmillan, 245--262.]]Google Scholar
- Jones, M. P. 1994. Qualified Types: Theory and Practice. Cambridge University Press.]] Google ScholarCross Ref
- Jones, M. P. 1995. From Hindley-Milner types to first-class structures. Res. Rep. YALEU/DCS/RR-1075, Yale University. June.]]Google Scholar
- Jones, S. P., Vytiniotis, D., Weirich, S., and Washburn, G. 2005. Simple unification-based type inference for GADTs. Submitted.]]Google Scholar
- Kuncak, V. and Rinard, M. 2003. Structural subtyping of non-recursive types is decidable. In Proceedings of the IEEE Symposium on Logic in Computer Science (LICS).]] Google ScholarDigital Library
- Läufer, K. and Odersky, M. 1994. Polymorphic type inference and abstract data types. ACM Trans. Program. Lang. Sys. 16, 5 (Sept.), 1411--1430.]] Google ScholarDigital Library
- Leroy, X., Doligez, D., Garrigue, J., Rémy, D., and Vouillon, J. 2005. The Objective Caml System.]]Google Scholar
- Maher, M. J. 1988. Complete axiomatizations of the algebras of finite, rational and infinite trees. In Proceedings of the IEEE Symposium on Logic in Computer Science (LICS). 348--357.]]Google ScholarCross Ref
- Milner, R. 1978. A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17, 3 (Dec.), 348--375.]]Google ScholarCross Ref
- Mitchell, J. C. 1984. Coercion and type inference. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL). 175--185.]] Google ScholarDigital Library
- Odersky, M. and Läufer, K. 1996. Putting type annotations to work. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL). 54--67.]] Google ScholarDigital Library
- Odersky, M., Sulzmann, M., and Wehr, M. 1999. Type inference with constrained types. Theory Practice Object Syst. 5, 1, 35--55.]] Google ScholarDigital Library
- Paulin-Mohring, C. 1992. Inductive definitions in the system Coq: Rules and properties. Res. Rep. RR1992-49, ENS Lyon.]]Google Scholar
- Peyton Jones, S. 1987. The Implementation of Functional Programming Languages. Prentice Hall, Upper Saddle River, NJ.]] Google ScholarDigital Library
- Peyton Jones, S., Ed. 2003. Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, New York.]]Google Scholar
- Peyton Jones, S. and Shields, M. 2004. Lexically-Scoped type variables. Manuscript.]]Google Scholar
- Peyton Jones, S., Washburn, G., and Weirich, S. 2004. Wobbly types: Type inference for generalised algebraic data types. Tech. Rep. MS-CIS-05-26, University of Pennsylvania. July.]]Google Scholar
- Pierce, B. C. and Turner, D. N. 2000. Local type inference. ACM Trans. Program. Lang. Syst. 22, 1 (Jan.), 1--44.]] Google ScholarDigital Library
- Pottier, F. and Gauthier, N. 2004. Polymorphic typed defunctionalization. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL). 89--98.]] Google ScholarDigital Library
- Pottier, F. and Régis-Gianas, Y. 2006. Stratified type inference for generalized algebraic data types. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL).]] Google ScholarDigital Library
- Pottier, F. and Rémy, D. 2005. The essence of ML type inference. In Advanced Topics in Types and Programming Languages, B. C. Pierce, Ed. MIT Press, Cambridge, MA. 389--489.]]Google Scholar
- Rémy, D. 1994. Programming objects with ML-ART: An extension to ML with abstract and record types. In Proceedings of the International Symposium on Theoretical Aspects of Computer Software (TACS). Springer Verlag, 321--346.]] Google ScholarDigital Library
- Sheard, T. 2004. Languages of the future. In Proceedings of the ACM Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA). 116--119.]] Google ScholarDigital Library
- Sheard, T. 2005. Ωmega.]]Google Scholar
- Sheard, T. and Pašalić, E. 2004. Meta-Programming with built-in type equality. In Proceedings of the Workshop on Logical Frameworks and Meta-Languages (LFM).]]Google Scholar
- Simonet, V. 2003. An extension of HM(X) with bounded existential and universal data-types. In Proceedings of the ACM International Conference on Functional Programming (ICFP).]] Google ScholarDigital Library
- Simonet, V. and Pottier, F. 2005. Constraint-Based type inference for guarded algebraic data types. Res. Rep. 5462, INRIA. Jan.]]Google Scholar
- Smith, G. S. 1994. Principal type schemes for functional programs with overloading and subtyping. Sci. Comput. Program. 23, 2--3 (Dec.), 197--226.]] Google ScholarDigital Library
- Stuckey, P. J. and Sulzmann, M. 2005. Type inference for guarded recursive data types. Manuscript.]]Google Scholar
- Sulzmann, M. 2000. A general framework for Hindley/Milner type systems with constraints. Ph.D. thesis, Yale University, Department of Computer Science.]] Google ScholarDigital Library
- Sulzmann, M., Müller, M., and Zenger, C. 1999. Hindley/Milner style type systems in constraint form. Res. Rep. ACRC-99-009, University of South Australia, School of Computer and Information Science. July.]]Google Scholar
- Trifonov, V. and Smith, S. 1996. Subtyping constrained types. In Proceedings of the Static Analysis Symposium (SAS). Lecture Notes in Computer Science, vol. 1145. Springer Verlag, 349--365.]] Google ScholarDigital Library
- Tse, S. and Zdancewic, S. 2004. Run-Time principals in information-flow type systems. In Proceedings of the IEEE Symposium on Security and Privacy (S and P).]]Google Scholar
- Vorobyov, S. G. 1996. An improved lower bound for the elementary theories of trees. In Proceedings of the International Conference on Automated Deduction (CADE). Lecture Notes in Computer Science, vol. 1104. Springer Verlag, 275--287.]] Google ScholarDigital Library
- Wadler, P. and Blott, S. 1989. How to make ad-hoc polymorphism less ad-hoc. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL). 60--76.]] Google ScholarDigital Library
- Warren, D. H. D. 1982. Higher-Order extensions to PROLOG: Are they needed? In Machine Intelligence 10, J. E. Hayes et al., Eds. Ellis Horwood, Upper Saddle River, NJ. 441--454.]]Google Scholar
- Weirich, S. 2000. Type-Safe cast: Functional pearl. In Proceedings of the ACM International Conference on Functional Programming (ICFP). 58--67.]] Google ScholarDigital Library
- Werner, B. 1994. Une théorie des constructions inductives. Ph.D. thesis, Université Paris 7.]]Google Scholar
- Wright, A. K. and Felleisen, M. 1994. A syntactic approach to type soundness. Infor. Comput. 115, 1 (Nov.), 38--94.]] Google ScholarDigital Library
- Xi, H. 1998. Dependent types in practical programming. Ph.D. thesis, Carnegie Mellon University.]] Google ScholarDigital Library
- Xi, H. 1999. Dead code elimination through dependent types. In Proceedings of the International Workshop on Practical Aspects of Declarative Languages (PADL). Lecture Notes in Computer Science, vol. 1551. Springer Verlag, 228--242.]] Google ScholarDigital Library
- Xi, H. 2001. Dependent ML.]]Google Scholar
- Xi, H. 2003. Dependently typed pattern matching. J. Universal Comput. Sci. 9, 8, 851--872.]]Google Scholar
- Xi, H. 2004. Applied type system. In Proceedings of the TYPES 2003 Conference. Lecture Notes in Computer Science, vol. 3085. Springer Verlag, 394--408.]]Google Scholar
- Xi, H., Chen, C., and Chen, G. 2003. Guarded recursive datatype constructors. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL). 224--235.]] Google ScholarDigital Library
- Xi, H. and Pfenning, F. 1999. Dependent types in practical programming. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL). 214--227.]] Google ScholarDigital Library
- Zenger, C. 1997. Indexed types. Theoretical Comput. Sci. 187, 147--165.]] Google ScholarDigital Library
- Zenger, C. 1998. Indizierte typen. Ph.D. thesis, Universität Karlsruhe.]]Google Scholar
Index Terms
- A constraint-based approach to guarded algebraic data types
Recommendations
The Essence of Generalized Algebraic Data Types
This paper considers direct encodings of generalized algebraic data types (GADTs) in a minimal suitable lambda-calculus. To this end, we develop an extension of System Fω with recursive types and internalized type equalities with injective constant type ...
Generalized algebraic data types and object-oriented programming
Proceedings of the 20th annual ACM SIGPLAN conference on Object oriented programming systems languages and applicationsGeneralized algebraic data types (GADTs) have received much attention recently in the functional programming community. They generalize the (type) parameterized algebraic datatypes (PADTs) of ML and Haskell by permitting value constructors to return ...
Pointwise generalized algebraic data types
TLDI '10: Proceedings of the 5th ACM SIGPLAN workshop on Types in language design and implementationIn the GADT (Generalized Algebraic Data Types) type system, a pattern-matching branch can draw type information from both the scrutinee type and the data constructor type. Even though the type system can handle complex interactions between the two types,...
Comments