skip to main content
article

Discriminative sum types locate the source of type errors

Published:25 August 2003Publication History
Skip Abstract Section

Abstract

We propose a type system for locating the source of type errors in an applied lambda calculus with ML-style polymorphism. The system is based on discriminative sum types---known from work on soft typing---with annotation subtyping and recursive types. This way, type clashes can be registered in the type for later reporting. The annotations track the potential producers and consumers for each value so that clashes can be traced to their cause.Every term is typeable in our system and type inference is decidable. A type derivation in our system describes all type errors present in the program, so that a principal derivation yields a principal description of all type errors present. Error messages are derived from completed type derivations. Thus, error messages are independent of the particular algorithm used for type inference, provided it constructs such a derivation.

References

  1. Martín Abadi, Butler Lampson, and Jean-Jacques Lévy. Analysis and caching of dependencies. In Kent Dybvig, editor, Proceedings of the 1996 International Conference on Functional Programming, pages 83--91, Philadelphia, PA, May 1996. ACM Press, New York.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. ACM. Proc. of the 13th Annual ACM Symposium on Principles of Programming Languages, St. Petersburg, Florida, 1986.]]Google ScholarGoogle Scholar
  3. Alexander Aiken, Edward L. Wimmers, and T.K. Lakshman. Soft typing with conditional types. In Proceedings of the 1994 ACM SIGPLAN Symposium on Principles of Programming Languages, Portland, OR, January 1994. ACM Press.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Franz Baader and Tobias Nipkow. Term Rewriting and All That. Cambridge University Press, 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. H. P. Barendregt. The Lambda Calculus --- Its Syntax and Semantics. North-Holland, 1984.]]Google ScholarGoogle Scholar
  6. Mike Beaven and Ryan Stansifer. Explaining type errors in polymorphic languages. ACM Letters on Programming Languages and Systems, 24):17--30, March 1993.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Robert Cartwright and Mike Fagan. Soft typing. In Proc. Conference on Programming Language Design and Implementation '91, pages 278--292, Toronto, Canada, June 1991. ACM.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Olaf Chitil. Compositional explanation of types and algorithmic debugging of type errors. In Xavier Leroy, editor, Proceedings of the 2001 International Conference on Functional Programming, Florence, Italy, September 2001. ACM Press, New York.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Dominique Clément, Joëlle Despeyroux, Thierry Despeyroux, and Gilles Kahn. A simple applicative language: Mini-ML. In Proceedings of the 1986 ACM Conference on Lisp and Functional Programming, pages 13--27, 1986.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Luis Damas. Type Assignment in Programming Languages. PhD thesis, Computer Science Department, Edinburgh University, 1985. report CST-33-85.]]Google ScholarGoogle Scholar
  11. Luis Damas and Robin Milner. Principal type-schemes for functional programs. In Proceedings of the 1982 ACM SIGPLAN Symposium on Principles of Programming Languages, pages 207--212. ACM Press, 1982.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Dominic Duggan and Frederick Bent. Explaining type inference. Science of Computer Programming, 271):37--83, July 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Cormac Flanagan and Matthias Felleisen. Componential set-based analysis. ACM Transactions on Programming Languages and Systems, 212):370--416, March 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Christian Haack and Joe Wells. Type error slicing in implicitly typed, higher-order languages. In Proc. 12th European Symposium on Programming, Lecture Notes in Computer Science, Warsaw, Poland, April 2003. Springer-Verlag.]]Google ScholarGoogle Scholar
  15. Bastiaan Heeren, Johan Jeuring, Doaitse Swierstra, and Pablo Azero Alcocer. Improving type-error messages in functional languages. Technical Report UU-CS-2002-009, Institute of Information and Computing Science, University Utrecht, Netherlands, February 2002. Technical Report.]]Google ScholarGoogle Scholar
  16. Nevin Heintze. Control-flow analysis and type systems. In Alan Mycroft, editor, Proceedings of the 1995 International Static Analysis Symposium, number 983 in Lecture Notes in Computer Science, pages 189--206, Glasgow, Scotland, September 1995. Springer-Verlag.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Fritz Henglein. Dynamic typing: Syntax and proof theory. Science of Computer Programming, 22:197--230, 1994.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Fritz Henglein and Jakob Rehof. Safe polymorphic type inference for a dynamically typed language: Translating Scheme to ML. In Simon Peyton Jones, editor, Proc. Functional Programming Languages and Computer Architecture 1995, La Jolla, CA, June 1995. ACM Press, New York.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Mark P. Jones. Qualified Types: Theory and Practice. Cambridge University Press, Cambridge, UK, 1994.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Oukseh Lee and Kwangkeun Yi. Proofs about a folklore let-polymorphic type inference algorithm. ACM Transactions on Programming Languages and Systems, 204):707--723, 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Bruce J. McAdam. On the Unification of Substitutions in Type Inference. In Kevin Hammond, Anthony J.T. Davie, and Chris Clack, editors, Implementation of Functional Languages IFL~'98), London, UK, number 1595 in Lecture Notes in Computer Science, pages 139--154. Springer-Verlag, September 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Robin Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 17:348--375, 1978.]]Google ScholarGoogle ScholarCross RefCross Ref
  23. John Mitchell. Foundations for Programming Languages. MIT Press, 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. John C. Mitchell. Type inference with simple subtypes. Journal of Functional Programming, 13):245--286, July 1991.]]Google ScholarGoogle ScholarCross RefCross Ref
  25. Martin Odersky, Martin Sulzmann, and Martin Wehr. Type inference with constrained types. Theory and Practice of Object Systems, 51):35--55, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Jens Palsberg and Patrick O'Keefe. A type system equivalent to flow analysis. In Proceedings of the 1995 ACM SIGPLAN Symposium on Principles of Programming Languages, pages 367--378, San Francisco, CA, January 1995. ACM Press.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Jens Palsberg and Christina Pavlopoulou. From polyvariant flow information to intersection and union types. In Luca Cardelli, editor, Proc. 25th Annual ACM Symposium on Principles of Programming Languages, pages 197--208, San Diego, CA, USA, January 1998. ACM Press.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. François Pottier. A versatile constraint-based type inference system. Nordic Journal of Computing, 74):312--347, November 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Didier Rémy. Typechecking records and variants in a natural extension of ML. In Proc. 16th Annual ACM Symposium on Principles of Programming Languages, pages 77--88, Austin, Texas, January 1989. ACM Press.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Didier Rémy. Projective ML. In Proc. 1992 ACM Conference on Lisp and Functional Programming, pages 66--75, San Francisco, California, USA, June 1992.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Didier Rémy. Type inference for records in a natural extension of ML. In Carl A. Gunter and John C. Mitchell, editors, Theoretical Aspects of Object-Oriented Programming: Types, Semantics, and Language Design. The MIT Press, 1994.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Christian Skalka and Scott Smith. Set types and applications. Electronic Notes in Theoretical Computer Science, 75, 2003.]]Google ScholarGoogle ScholarCross RefCross Ref
  33. Janet A. Walz and Gregory F. Johnson. A maximium flow approach to anomaly isolation in unification-based incremental type inference. In POPL1986 {2}, pages 44--57.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Mitchell Wand. Finding the source of type errors. In POPL1986 {2}, pages 38--43.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Mitchell Wand. Type inference for record concatenation and multiple inheritance. In Proceedings of the 1989 IEEE Symposium on Logic in Computer Science, pages 92--97, Pacific Grove, CA, June 1989. IEEE Computer Society Press. To appear in Information and Computation.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Mitchell Wand. Type inference for record concatenation and multiple inheritance. Information and Computation, 931):1--15, July 1991.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Joseph B. Wells. The essence of principal typings. In Proc. 29th Int'l Coll. Automata, Languages, and Programming, number 2380 in Lecture Notes in Computer Science, pages 913--925. Springer-Verlag, 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Andrew K. Wright and Robert Cartwright. A practical soft type system for Scheme. ACM Transactions on Programming Languages and Systems, 191):87--152, January 1997.]] Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Discriminative sum types locate the source of type errors

        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 SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 38, Issue 9
          September 2003
          289 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/944746
          Issue’s Table of Contents
          • cover image ACM Conferences
            ICFP '03: Proceedings of the eighth ACM SIGPLAN international conference on Functional programming
            August 2003
            310 pages
            ISBN:1581137567
            DOI:10.1145/944705

          Copyright © 2003 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: 25 August 2003

          Check for updates

          Qualifiers

          • article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader