Skip to main content

An Embedded Type Debugger

  • Conference paper
  • First Online:
Implementation and Application of Functional Languages (IFL 2012)

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

Included in the following conference series:

Abstract

This paper presents how to build a type debugger without implementing any dedicated type inferencer. Previous type debuggers required their own type inferencers apart from the compiler’s type inferencer. The advantage of our approach is threefold. First, by not implementing a type inferencer, it is guaranteed that the debugger’s type inference never disagrees with the compiler’s type inference. Secondly, we can avoid the pointless reproduction of a type inferencer that should work precisely as the compiler’s type inferencer. Thirdly, our approach is robust to updates of the underlying language. The key observation of our approach is that the interactive type debugging, as proposed by Chitil, does not require a type inference tree but only a tree with a certain simple property. We identify the property and present how to construct a tree that satisfies this property using the compiler’s type inferencer. The property guides us how to build a type debugger for various language constructs. In this paper, we describe our idea and first apply it to the simply-typed lambda calculus. After that, we extend it with let-polymorphism and objects to see how our technique scales.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 54.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 72.00
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

Institutional subscriptions

Notes

  1. 1.

    This is an example of the source of this type error. If the programmer has a different intention, other fixes are possible, such as replacing true with 1.

  2. 2.

    Before, we wrote \(\varGamma _0 \vdash \lambda x. [x + 1] : \mathtt{int -> [int] }\) to emphasize that we are using the compiler’s type inferencer to infer the type of \(M\) in \(C\). Since we are interested in the type of \(M\) itself together with the types of its free variables, we also write it using the standard notation \(\varGamma _0, x:\mathtt{int } \vdash x + 1 : \mathtt{int }\).

References

  1. 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’01), pp. 193–204 (2001)

    Google Scholar 

  2. Garrigue, J.: Relaxing the value restriction. In: Kameyama, Y., Stuckey, P.J. (eds.) FLOPS 2004. LNCS, vol. 2998, pp. 196–213. Springer, Heidelberg (2004)

    Google Scholar 

  3. Haack, C., Wells, J.B.: Type error slicing in implicitly typed higher-order languages. In: Degano, P. (ed.) ESOP 2003. LNCS, vol. 2618, pp. 284–301. Springer, Heidelberg (2003)

    Google Scholar 

  4. Hall, C., Hammond, K., Jones, S.P., Wadler, P.: Type classes in Haskell. ACM Trans. Program. Lang. Syst. (TOPLAS) 18(2), 241–256 (1996)

    Article  Google Scholar 

  5. Heeren, B., Hage, J.: Parametric type inferencing for Helium. Technical Report UU-CS-2002-035, Utrecht University (2002)

    Google Scholar 

  6. Lee, O., Yi, K.: Proofs about a folklore let-polymorphic type inference algorithm. ACM Trans. Program. Lang. Syst. 20(4), 707–723 (1998)

    Article  Google Scholar 

  7. Lerner, B.S., Flower, M., Grossman, D., Chambers, C.: Searching for type-error messages. In: Proceedings of the 2007 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’07), pp. 425–434 (2007)

    Google Scholar 

  8. McAdam, B.J.: Generalising techniques for type debugging, chapter 6. In: Trinder, P., Michaelson, G., Loidl, H.-W. (eds.) Trends in Functional Programming, pp. 49–57. Intellect, Portland (2000)

    Google Scholar 

  9. Nilsson, H.: Declarative debugging for lazy functional languages. Ph.D. thesis, Linköping, Sweden (1998)

    Google Scholar 

  10. Schilling, T.: Constraint-free type error slicing. In: Peña, R., Page, R. (eds.) TFP 2011. LNCS, vol. 7193, pp. 1–16. Springer, Heidelberg (2012)

    Google Scholar 

  11. Shapiro, E.Y.: Algorithmic program debugging. MIT Press, Cambridge (1983)

    Google Scholar 

  12. Silva, J., Chitil, O.: Combining algorithmic debugging and program slicing. In: Proceedings of the 8th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP’06), pp. 157–166 (2006)

    Google Scholar 

  13. Simon, A., Chitil, O., Huch, F.: Typeview: a tool for understanding type errors. In: Draft Proceedings of the 12th International Workshop on Implementation of Functional Languages, pp. 63–69 (2000)

    Google Scholar 

  14. Stuckey, P. J., Sulzmann, M., Wazny, J.: Interactive type debugging in Haskell. In: Proceedings of the 2003 ACM SIGPLAN Workshop on Haskell (Haskell’03), pp. 72–83 (2003)

    Google Scholar 

  15. Tsushima, K., Asai, K.: Report on an OCaml type debugger. In: ACM SIGPLAN Workshop on ML, 3 p. (2011)

    Google Scholar 

  16. Wand, M.: Finding the source of type errors. In: Proceedings of the 13th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL’86), pp. 38–43 (1986)

    Google Scholar 

Download references

Aknowledgements

We would like to thank Olaf Chitil, Olivier Danvy, Ian Zerny, IFL participants, and anonymous reviewers for valuable comments and discussions.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Kanae Tsushima .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2013 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Tsushima, K., Asai, K. (2013). An Embedded Type Debugger. In: Hinze, R. (eds) Implementation and Application of Functional Languages. IFL 2012. Lecture Notes in Computer Science(), vol 8241. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-41582-1_12

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-41582-1_12

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-41581-4

  • Online ISBN: 978-3-642-41582-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics