On the Unification of Substitutions in Type Inference

  • Bruce J. McAdam
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1595)

Abstract

The response of compilers to programs with type errors can be unpredictable and confusing. In part this is because the point at which type inference fails may not be the point at which the programmer has made a mistake. This paper explores a way of making type inference algorithms fail at different locations in programs so that clearer error messages may then be produced.

Critical to the operation of type inference algorithms is their use of substitutions. We will see that the way in which substitutions are applied in type inference algorithm W means that errors are detected towards the right-hand side of expressions. This paper introduces a new operation — unification of substitutions — which allows greater control over the use of substitutions so that this bias can be removed.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    M. Beaven and R. Stansifer. Explaining Type Errors in Polymorphic Languages. ACM Letters on Programming Languages and Systems, 2(1):17–30, March 1993.CrossRefGoogle Scholar
  2. 2.
    K.L. Bernstein and E.W. Stark. Debugging Type Errors (Full version). Technical report, State University of New York at Stony Brook, Computer Science Department, November 1995. http://www.cs.sunysb.edu/~stark/REPORTS/INDEX.html.
  3. 3.
    L. Cardelli. Basic Polymorphic Type-Checking. Science of Computer Programming, 8(2):147–172, 1987.MATHCrossRefMathSciNetGoogle Scholar
  4. 4.
    L.M.M. Damas. Type Assignment in Programming Languages. PhD thesis, Department of Computer Science, The University of Edinburgh, April 1985. CST-33-85.Google Scholar
  5. 5.
    L.M.M. Damas and A.J.R.G. Milner. Principal Type-Schemes for Functional Programs. In Proc. 9th. ACM Symposium on Principles of Programming Languages (POPL’ 82), pages 207–212, 1982.Google Scholar
  6. 6.
    D. Duggan and F. Bent. Explaining Type Inference. Science of Computer Programming, (27):37–83, 1996.MATHCrossRefGoogle Scholar
  7. 7.
    G.F. Johnson and J.A. Walz. A Maximum-Flow Approach to Anomaly Isolation in Unification-Based Incremental Type-Inference. In Proc. 13th. ACM Symposium on Principles of Programming Languages (POPL’ 86), pages 44–57, 1986.Google Scholar
  8. 8.
    K. Knight. Unification: A Multidisciplinary Survey. ACM Computing Surveys, 21(1):93–124, 1989.MATHCrossRefMathSciNetGoogle Scholar
  9. 9.
    O. Lee and K. Yi. Proofs About a Folklore Let-Polymorphic Type Inference Algorithm. ACM Transactions on Programming Languages and Systems, 1999. To Appear.Google Scholar
  10. 10.
    B.J. McAdam. On the Unification of Substitutions in Type-Inference. Technical Report ECS-LFCS-98-384, Laboratory for Foundations of Computer Science, The University of Edinburgh, James Clerk Maxwell Building, The Kings Buildings, Mayfield Road, Edinburgh, UK, March 1998.Google Scholar
  11. 11.
    S.L. Peyton Jones and P.L. Wadler. Imperative Functional Programming. In Proc. 20th. ACM Symposium on Principles of Programming Languages (POPL’ 93), pages 71–84, January 1993.Google Scholar
  12. 12.
    M. Tofte. Four Lectures on Standard ML. Technical Report ECS-LFCS-89-73, Laboratory for Foundations of Computer Science, The University of Edinburgh, March 1989.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1999

Authors and Affiliations

  • Bruce J. McAdam
    • 1
  1. 1.Laboratory for Foundations of Computer ScienceThe University of EdinburghUSA

Personalised recommendations