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.
- 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 ScholarDigital Library
- ACM. Proc. of the 13th Annual ACM Symposium on Principles of Programming Languages, St. Petersburg, Florida, 1986.]]Google Scholar
- 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 ScholarDigital Library
- Franz Baader and Tobias Nipkow. Term Rewriting and All That. Cambridge University Press, 1998.]] Google ScholarDigital Library
- H. P. Barendregt. The Lambda Calculus --- Its Syntax and Semantics. North-Holland, 1984.]]Google Scholar
- Mike Beaven and Ryan Stansifer. Explaining type errors in polymorphic languages. ACM Letters on Programming Languages and Systems, 24):17--30, March 1993.]] Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- Luis Damas. Type Assignment in Programming Languages. PhD thesis, Computer Science Department, Edinburgh University, 1985. report CST-33-85.]]Google Scholar
- 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 ScholarDigital Library
- Dominic Duggan and Frederick Bent. Explaining type inference. Science of Computer Programming, 271):37--83, July 1996.]] Google ScholarDigital Library
- Cormac Flanagan and Matthias Felleisen. Componential set-based analysis. ACM Transactions on Programming Languages and Systems, 212):370--416, March 1999.]] Google ScholarDigital Library
- 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 Scholar
- 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 Scholar
- 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 ScholarDigital Library
- Fritz Henglein. Dynamic typing: Syntax and proof theory. Science of Computer Programming, 22:197--230, 1994.]] Google ScholarDigital Library
- 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 ScholarDigital Library
- Mark P. Jones. Qualified Types: Theory and Practice. Cambridge University Press, Cambridge, UK, 1994.]] Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- Robin Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 17:348--375, 1978.]]Google ScholarCross Ref
- John Mitchell. Foundations for Programming Languages. MIT Press, 1996.]] Google ScholarDigital Library
- John C. Mitchell. Type inference with simple subtypes. Journal of Functional Programming, 13):245--286, July 1991.]]Google ScholarCross Ref
- Martin Odersky, Martin Sulzmann, and Martin Wehr. Type inference with constrained types. Theory and Practice of Object Systems, 51):35--55, 1999.]] Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- François Pottier. A versatile constraint-based type inference system. Nordic Journal of Computing, 74):312--347, November 2000.]] Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- Christian Skalka and Scott Smith. Set types and applications. Electronic Notes in Theoretical Computer Science, 75, 2003.]]Google ScholarCross Ref
- 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 ScholarDigital Library
- Mitchell Wand. Finding the source of type errors. In POPL1986 {2}, pages 38--43.]] Google ScholarDigital Library
- 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 ScholarDigital Library
- Mitchell Wand. Type inference for record concatenation and multiple inheritance. Information and Computation, 931):1--15, July 1991.]] Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
Index Terms
- Discriminative sum types locate the source of type errors
Recommendations
Discriminative sum types locate the source of type errors
ICFP '03: Proceedings of the eighth ACM SIGPLAN international conference on Functional programmingWe 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. ...
Polymorphic type inference and abstract data types
Many statically typed programming languages provide an abstract data type construct, such as the module in Modula-2. However, in most of these languages, implementations of abstract data types are not first-class values. Thus, they cannot be assigned to ...
Type inference for unboxed types and first class mutability
PLOS '06: Proceedings of the 3rd workshop on Programming languages and operating systems: linguistic support for modern operating systemsSystems programs rely on fine-grain control of data representation and use of state to achieve performance, conformance to hard-ware specification, and temporal predictability. The robustness and checkability of these programs could be greatly improved ...
Comments