Blame Tracking and Type Error Debugging

In this work, we present an unexpected connection between gradual typing and type error debugging. Namely, we illustrate that gradual typing provides a natural way to defer type errors in statically illtyped programs, providing more feedback than traditional approaches to deferring type errors. When evaluating expressions that lead to runtime type errors, the usefulness of the feedback depends on blame tracking, the defacto approach to locating the cause of such runtime type errors. Unfortunately, blame tracking suffers from the bias problem for type error localization in languages with type inference. We illustrate and formalize the bias problem for blame tracking, present ideas for adapting existing type error debugging techniques to combat this bias, and outline further challenges. 2012 ACM Subject Classification Theory of computation → Type structures

[1]  Martin Erwig,et al.  Systematic identification and communication of type errors , 2018, J. Funct. Program..

[2]  Sam Tobin-Hochstadt,et al.  Interlanguage migration: from scripts to programs , 2006, OOPSLA '06.

[3]  Martin Erwig,et al.  Exploiting diversity in type checkers for better error messages , 2017, J. Vis. Lang. Comput..

[4]  Peter J. Stuckey,et al.  Interactive type debugging in Haskell , 2003, Haskell '03.

[5]  Jeremy G. Siek Gradual Typing for Functional Languages , 2006 .

[6]  Mitchell Wand Finding the source of type errors , 1986, POPL '86.

[7]  Kwangkeun Yi,et al.  Proofs of a set of hybrid let-polymorphic type inference algorithms , 2009, New Generation Computing.

[8]  Gavin M. Bierman,et al.  Adding Dynamic Types to C# , 2010, ECOOP.

[9]  Zvonimir Pavlinovic,et al.  Practical SMT-based type error localization , 2015, ICFP.

[10]  Premkumar T. Devanbu,et al.  A large scale study of programming languages and code quality in github , 2014, SIGSOFT FSE.

[11]  Avik Chaudhuri,et al.  Fast and precise type checking for JavaScript , 2017, Proc. ACM Program. Lang..

[12]  J. A. Robinson,et al.  A Machine-Oriented Logic Based on the Resolution Principle , 1965, JACM.

[13]  Peter J. Stuckey,et al.  Improving type error diagnosis , 2004, Haskell '04.

[14]  Philip Wadler,et al.  Blame and coercion: together again for the first time , 2015, Journal of Functional Programming.

[15]  Martin Erwig,et al.  Counter-factual typing for debugging type errors , 2014, POPL.

[16]  Benjamin C. Pierce,et al.  Types and programming languages: the next generation , 2003, 18th Annual IEEE Symposium of Logic in Computer Science, 2003. Proceedings..

[17]  Sam Tobin-Hochstadt,et al.  The design and implementation of typed scheme , 2008, POPL '08.

[18]  Martin Erwig,et al.  Guided Type Debugging , 2014, FLOPS.

[19]  Jurriaan Hage,et al.  Heuristics for Type Error Discovery and Recovery , 2006, IFL.

[20]  Peter Thiemann,et al.  Discriminative sum types locate the source of type errors , 2003, ICFP '03.

[21]  Kamalika Chaudhuri,et al.  Learning to Blame: Localizing Novice Type Errors with Data-Driven Diagnosis , 2017 .

[22]  Gregory F. Johnson,et al.  A maximum-flow approach to anomaly isolation in unification-based incremental type inference , 1986, POPL '86.

[23]  Philip Wadler,et al.  Theorems for free for free: parametricity, with and without types , 2017, Proc. ACM Program. Lang..

[24]  Christopher Scaffidi,et al.  The function, and dysfunction, of information sources in learning functional programming , 2012 .

[25]  Sam Tobin-Hochstadt,et al.  Monotonic References for Efficient Gradual Typing , 2015, ESOP.

[26]  Gavin M. Bierman,et al.  Safe & Efficient Gradual Typing for TypeScript , 2015, POPL.

[27]  Manish Vachharajani,et al.  Gradual typing with unification-based inference , 2008, DLS '08.

[28]  Olaf Chitil,et al.  A Common Framework Using Expected Types for Several Type Debugging Approaches , 2018, FLOPS.

[29]  Ville Tirronen,et al.  Understanding beginners' mistakes with Haskell , 2015, Journal of Functional Programming.

[30]  Giuseppe Castagna,et al.  Gradual typing with union and intersection types , 2017, Proc. ACM Program. Lang..

[31]  Kwangkeun Yi,et al.  A Generalized Let-Polymorphic Type Inference Algorithm , 2000 .

[32]  Nick Benton,et al.  Implementation and Application of Functional Languages , 2005 .

[33]  Atsushi Igarashi,et al.  Gradual typing for generics , 2011, OOPSLA '11.

[34]  Matteo Cimini,et al.  Principal Type Schemes for Gradual Programs , 2015, POPL.

[35]  Avik Chaudhuri,et al.  The ins and outs of gradual type inference , 2012, POPL '12.

[36]  Atsushi Igarashi,et al.  Dynamic type inference for gradual Hindley–Milner typing , 2018, Proc. ACM Program. Lang..

[37]  Olaf Chitil,et al.  Compositional explanation of types and algorithmic debugging of type errors , 2001, ICFP '01.

[38]  Martin Erwig,et al.  Migrating gradual types , 2018, Proc. ACM Program. Lang..

[39]  T. B. Dinesh,et al.  Centrum Voor Wiskunde En Informatica Reportrapport a Slicing-based Approach for Locating Type Errors a Slicing-based Approach for Locating Type Errors , 2022 .

[40]  Philip Wadler,et al.  Blame for all , 2011, POPL '11.

[41]  Atsushi Igarashi,et al.  On polymorphic gradual typing , 2017, Proc. ACM Program. Lang..

[42]  Dan Grossman,et al.  Searching for type-error messages , 2007, PLDI '07.

[43]  John Tang Boyland,et al.  Refined Criteria for Gradual Typing , 2015, SNAPL.

[44]  Philip Wadler,et al.  A Complement to Blame , 2015, SNAPL.

[45]  Eric Walkingshaw,et al.  Casts and costs: harmonizing safety and performance in gradual typing , 2018, Proc. ACM Program. Lang..

[46]  Thomas Schilling,et al.  Constraint-Free Type Error Slicing , 2011, Trends in Functional Programming.