Skip to main content

Explaining ML Type Errors by Data Flows

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 3474))

Abstract

We present a novel approach to explaining ML type errors: Since the type system inhibits data flows that would abort the program at run-time, our type checker identifies as explanations those data flows that violate the typing rules. It also detects the notorious backflows, which are artifacts of unification, and warns the user about the possibly unexpected typing. The generated explanations comprise a detailed textual description and an arrow overlay to the source code, in which each arrowrepresents one data flow. The description refers only to elementary facts about program evaluation, not to the type checking process itself. The method integrates well with unification-based type checking: Type-correct programs incur a modest overhead compared to normal type checking. If a type error occurs, a simple depth-first graph traversal yields the explanation. A proof-of-concept implementation is available.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Aiken, A., Wimmers, E.L.: Type inclusion constraints and type inference. In: Conference on Functional Programming Languages and Computer Architecture, pp. 31–41. ACM press, New York (1993)

    Chapter  Google Scholar 

  2. Baader, F., Snyder, W.: Unification theory. In: Robinson, A., Voronkov, A. (eds.) Handbook of automated reasoning, vol. I, ch. 8, pp. 445–533. Elsevier Science, Amsterdam (2001)

    Google Scholar 

  3. Beaven, M., Stansifer, R.: Explaining type errors in polymorphic languages. ACM Letters on Programming Languages and Systems 2(1–4), 17–30 (1993)

    Article  Google Scholar 

  4. Braßel, B.: TypeHope: There is hope for your type errors. In: Grelck, C., Huch, F., Michaelson, G.J., Trinder, P. (eds.) IFL 2004. LNCS, vol. 3474. Springer, Heidelberg (2005); University of Kiel. Report 0408

    Google Scholar 

  5. Chitil, O.: Compositional explanation of types and algorithmic debugging of type errors. In: Proceedings of the Sixth ACM SIGPLAN International Conference on Functional Programming (ICFP 2001), Florence, Italy, pp. 193–204 (2001)

    Google Scholar 

  6. Duggan, D., Bent, F.: Explaining type inference. Science of Computer Programming 27(1), 37–83 (1996)

    Article  MATH  Google Scholar 

  7. Eifrig, J., Smith, S., Trifonov, V.: Type inference for recursively constrained types and its application to OOP. Electronic Notes in Theoretical Computer Science, vol. 1 (1995)

    Google Scholar 

  8. Flanagan, C., Flatt, M., Krishnamurthi, S., Weirich, S., Felleisen, M.: Catching bugs in the web of program invariants. ACM SIGPLAN Notices 31(5), 23–32 (1996)

    Article  Google Scholar 

  9. Gallier, J.H.: Logic for Computer Science – Foundations of Automatic Theorem Proving. Harper & Row Publishers, New York (1986)

    MATH  Google Scholar 

  10. Haack, C., Wells, J.B.: Type error slicing in implicitly typed higher-order languages. Science of Computer Programming 50(1–3), 189–224 (2004); Special issue on 12th European symposium on programming (ESOP 2003)

    Google Scholar 

  11. Hansen, J., Shafarenko, A.: Type error reporting in a single-assignment language with homomorphic overloading. In: International Workshop on the Implementation of Functional Languages, Edinburgh, Schottland (September 2003)

    Google Scholar 

  12. Heeren, B., Hage, J., Swierstra, D.: Generalizing Hindley-Milner type-inference algorithms. Technical Report UU-CS-2002-031, Institute of Information and Computing Sciences, Utrecht University (2002)

    Google Scholar 

  13. Heeren, B., Hage, J., Swierstra, S.D.: Scripting the type inference process. ACM SIGPLAN Notices 38(9) (September 2003)

    Google Scholar 

  14. Hoang, M., Mitchell, J.C.: Lower bounds on type inference with subtypes. In: Conference Record of POPL 1995: 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, San Francisco, California, January 23-25, 1995. ACM Press, New York (1995)

    Google Scholar 

  15. Martelli, A., Montanari, U.: An efficient unification algorithm. ACM Transactions on Programming Languages and Systems 4(2), 258–282 (1982)

    Article  MATH  Google Scholar 

  16. McAdam, B.J.: Repairing Type Errors in Functional Programs. PhD thesis, Division of Informatics, University of Edinburgh (2002)

    Google Scholar 

  17. Milner, R.: A theory of type polymorphism in programming. Journal of Computer and System Sciences 17, 348–375 (1978)

    Article  MATH  MathSciNet  Google Scholar 

  18. Mitchell, J.C.: Type inference with simple subtypes. Journal of Functional Programming 1(3), 245–285 (1991)

    Article  MATH  MathSciNet  Google Scholar 

  19. Neubauer, M., Thiemann, P.: Discriminative sum types locate the source of type errors. In: Proceedings of the 8th ACM SIGPLAN International Conference on Functional Programming, Uppsala, Sweden, pp. 15–26. ACM, New York (2003)

    Chapter  Google Scholar 

  20. Objective Caml 3.08 (July 2004), http://caml.inria.fr

  21. Stuckey, P.J., Sulzmann, M., Wazny, J.: Improving type error diagnosis. In: Proceedings of Haskell Workshop (Haskell 2004) (May 2004) (to appear)

    Google Scholar 

  22. Tip, F., Dinesh, T.B.: A slicing-based approach for locating type errors. ACM Transactions on Software Engineering and Methodology 10(1), 5–55 (2001)

    Article  Google Scholar 

  23. Wand, M.: Finding the source of type errors. In: Proceedings of the 13th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, pp. 38–43. ACM Press, New York (1986)

    Chapter  Google Scholar 

  24. Wand, M.: A simple algorithm and proof for type inference. Fundamenta Informaticae 10, 115–122 (1987)

    MATH  MathSciNet  Google Scholar 

  25. Wright, A.K.: Practical Soft Typing. PhD thesis, Rice University, Houston,Texas (August 1994)

    Google Scholar 

  26. Yang, J.: Improving polymorphic type explanations. PhD thesis, Department of Computing and Electrical Engineering, Heriot-Watt University (October 2001)

    Google Scholar 

  27. Yang, J., Michaelson, G., Trinder, P.: Explaining polymorphic types. The Computer Journal 45(4), 436–452 (2002)

    Article  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2005 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Gast, H. (2005). Explaining ML Type Errors by Data Flows. In: Grelck, C., Huch, F., Michaelson, G.J., Trinder, P. (eds) Implementation and Application of Functional Languages. IFL 2004. Lecture Notes in Computer Science, vol 3474. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11431664_5

Download citation

  • DOI: https://doi.org/10.1007/11431664_5

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-26094-3

  • Online ISBN: 978-3-540-32038-8

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics