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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 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.
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
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)
Garrigue, J.: Relaxing the value restriction. In: Kameyama, Y., Stuckey, P.J. (eds.) FLOPS 2004. LNCS, vol. 2998, pp. 196–213. Springer, Heidelberg (2004)
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)
Hall, C., Hammond, K., Jones, S.P., Wadler, P.: Type classes in Haskell. ACM Trans. Program. Lang. Syst. (TOPLAS) 18(2), 241–256 (1996)
Heeren, B., Hage, J.: Parametric type inferencing for Helium. Technical Report UU-CS-2002-035, Utrecht University (2002)
Lee, O., Yi, K.: Proofs about a folklore let-polymorphic type inference algorithm. ACM Trans. Program. Lang. Syst. 20(4), 707–723 (1998)
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)
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)
Nilsson, H.: Declarative debugging for lazy functional languages. Ph.D. thesis, Linköping, Sweden (1998)
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)
Shapiro, E.Y.: Algorithmic program debugging. MIT Press, Cambridge (1983)
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)
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)
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)
Tsushima, K., Asai, K.: Report on an OCaml type debugger. In: ACM SIGPLAN Workshop on ML, 3 p. (2011)
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)
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
Corresponding author
Editor information
Editors and Affiliations
Rights 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)