An Embedded Type Debugger

  • Kanae TsushimaEmail author
  • Kenichi Asai
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8241)


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.



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


  1. 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. 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. 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. 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)CrossRefGoogle Scholar
  5. 5.
    Heeren, B., Hage, J.: Parametric type inferencing for Helium. Technical Report UU-CS-2002-035, Utrecht University (2002)Google Scholar
  6. 6.
    Lee, O., Yi, K.: Proofs about a folklore let-polymorphic type inference algorithm. ACM Trans. Program. Lang. Syst. 20(4), 707–723 (1998)CrossRefGoogle Scholar
  7. 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. 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. 9.
    Nilsson, H.: Declarative debugging for lazy functional languages. Ph.D. thesis, Linköping, Sweden (1998)Google Scholar
  10. 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. 11.
    Shapiro, E.Y.: Algorithmic program debugging. MIT Press, Cambridge (1983)Google Scholar
  12. 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. 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. 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. 15.
    Tsushima, K., Asai, K.: Report on an OCaml type debugger. In: ACM SIGPLAN Workshop on ML, 3 p. (2011)Google Scholar
  16. 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

Copyright information

© Springer-Verlag Berlin Heidelberg 2013

Authors and Affiliations

  1. 1.Ochanomizu UniversityTokyoJapan

Personalised recommendations