skip to main content
article
Open Access

A constraint-based approach to guarded algebraic data types

Published:01 January 2007Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

References

  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 ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. Cheney, J. and Hinze, R. 2002. A lightweight implementation of generics and dynamics. In Proceedings of the Haskell Workshop.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Cheney, J. and Hinze, R. 2003. First-Class phantom types. Tech. Rep. 1901, Cornell University.]]Google ScholarGoogle Scholar
  5. Comon, H. and Lescanne, P. 1989. Equational problems and disunification. J. Symb. Comput. 7, 371--425.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Crary, K., Weirich, S., and Morrisett, G. 2002. Intensional polymorphism in type erasure semantics. J. Functional Program. 12, 6 (Nov.), 567--600.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Curtis, P. 1990. Constrained quantification in polymorphic type analysis. Ph.D. thesis, Cornell University.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. Hanus, M. 1988. Horn clause specifications with polymorphic types. Ph.D. thesis, Fachbereich Informatik, Universität Dortmund.]]Google ScholarGoogle Scholar
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. Henglein, F. 1993. Type inference with polymorphic recursion. ACM Trans. Program. Lang. Syst. 15, 2 (Apr.), 253--289.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Hindley, J. R. 1969. The principal type-scheme of an object in combinatory logic. Trans. Am. Math. Soc. 146, 29--60.]]Google ScholarGoogle Scholar
  13. Hinze, R. 2003. Fun with phantom types. In The Fun of Programming, J. Gibbons and O. de Moor, Eds. Palgrave Macmillan, 245--262.]]Google ScholarGoogle Scholar
  14. Jones, M. P. 1994. Qualified Types: Theory and Practice. Cambridge University Press.]] Google ScholarGoogle ScholarCross RefCross Ref
  15. Jones, M. P. 1995. From Hindley-Milner types to first-class structures. Res. Rep. YALEU/DCS/RR-1075, Yale University. June.]]Google ScholarGoogle Scholar
  16. Jones, S. P., Vytiniotis, D., Weirich, S., and Washburn, G. 2005. Simple unification-based type inference for GADTs. Submitted.]]Google ScholarGoogle Scholar
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. Leroy, X., Doligez, D., Garrigue, J., Rémy, D., and Vouillon, J. 2005. The Objective Caml System.]]Google ScholarGoogle Scholar
  20. 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 ScholarGoogle ScholarCross RefCross Ref
  21. Milner, R. 1978. A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17, 3 (Dec.), 348--375.]]Google ScholarGoogle ScholarCross RefCross Ref
  22. Mitchell, J. C. 1984. Coercion and type inference. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL). 175--185.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  24. Odersky, M., Sulzmann, M., and Wehr, M. 1999. Type inference with constrained types. Theory Practice Object Syst. 5, 1, 35--55.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Paulin-Mohring, C. 1992. Inductive definitions in the system Coq: Rules and properties. Res. Rep. RR1992-49, ENS Lyon.]]Google ScholarGoogle Scholar
  26. Peyton Jones, S. 1987. The Implementation of Functional Programming Languages. Prentice Hall, Upper Saddle River, NJ.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Peyton Jones, S., Ed. 2003. Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, New York.]]Google ScholarGoogle Scholar
  28. Peyton Jones, S. and Shields, M. 2004. Lexically-Scoped type variables. Manuscript.]]Google ScholarGoogle Scholar
  29. 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 ScholarGoogle Scholar
  30. Pierce, B. C. and Turner, D. N. 2000. Local type inference. ACM Trans. Program. Lang. Syst. 22, 1 (Jan.), 1--44.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Pottier, F. and Gauthier, N. 2004. Polymorphic typed defunctionalization. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL). 89--98.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  33. 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 ScholarGoogle Scholar
  34. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  35. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  36. Sheard, T. 2005. Ωmega.]]Google ScholarGoogle Scholar
  37. 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 ScholarGoogle Scholar
  38. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  39. Simonet, V. and Pottier, F. 2005. Constraint-Based type inference for guarded algebraic data types. Res. Rep. 5462, INRIA. Jan.]]Google ScholarGoogle Scholar
  40. Smith, G. S. 1994. Principal type schemes for functional programs with overloading and subtyping. Sci. Comput. Program. 23, 2--3 (Dec.), 197--226.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Stuckey, P. J. and Sulzmann, M. 2005. Type inference for guarded recursive data types. Manuscript.]]Google ScholarGoogle Scholar
  42. Sulzmann, M. 2000. A general framework for Hindley/Milner type systems with constraints. Ph.D. thesis, Yale University, Department of Computer Science.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. 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 ScholarGoogle Scholar
  44. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  45. 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 ScholarGoogle Scholar
  46. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  47. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  48. 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 ScholarGoogle Scholar
  49. Weirich, S. 2000. Type-Safe cast: Functional pearl. In Proceedings of the ACM International Conference on Functional Programming (ICFP). 58--67.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. Werner, B. 1994. Une théorie des constructions inductives. Ph.D. thesis, Université Paris 7.]]Google ScholarGoogle Scholar
  51. Wright, A. K. and Felleisen, M. 1994. A syntactic approach to type soundness. Infor. Comput. 115, 1 (Nov.), 38--94.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. Xi, H. 1998. Dependent types in practical programming. Ph.D. thesis, Carnegie Mellon University.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  54. Xi, H. 2001. Dependent ML.]]Google ScholarGoogle Scholar
  55. Xi, H. 2003. Dependently typed pattern matching. J. Universal Comput. Sci. 9, 8, 851--872.]]Google ScholarGoogle Scholar
  56. 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 ScholarGoogle Scholar
  57. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  58. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  59. Zenger, C. 1997. Indexed types. Theoretical Comput. Sci. 187, 147--165.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  60. Zenger, C. 1998. Indizierte typen. Ph.D. thesis, Universität Karlsruhe.]]Google ScholarGoogle Scholar

Index Terms

  1. A constraint-based approach to guarded algebraic data types

            Recommendations

            Comments

            Login options

            Check if you have access through your login credentials or your institution to get full access on this article.

            Sign in

            Full Access

            • Published in

              cover image ACM Transactions on Programming Languages and Systems
              ACM Transactions on Programming Languages and Systems  Volume 29, Issue 1
              January 2007
              273 pages
              ISSN:0164-0925
              EISSN:1558-4593
              DOI:10.1145/1180475
              Issue’s Table of Contents

              Copyright © 2007 ACM

              Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

              Publisher

              Association for Computing Machinery

              New York, NY, United States

              Publication History

              • Published: 1 January 2007
              Published in toplas Volume 29, Issue 1

              Permissions

              Request permissions about this article.

              Request Permissions

              Check for updates

              Qualifiers

              • article

            PDF Format

            View or Download as a PDF file.

            PDF

            eReader

            View online with eReader.

            eReader