Bidirectional Type Slicing
Summary
This paper introduces a theory of bidirectional type slicing, where selecting a term and querying its type information yields a minimal program slice sufficient to explain that type. The metatheory is mechanised in Agda and a linear-time approximation is implemented for the Hazel programming environment.
View Cached Full Text
Cached at: 10/06/26, 03:25 PM
# Bidirectional Type Slicing Source: [https://arxiv.org/abs/2607.12197](https://arxiv.org/abs/2607.12197) [View PDF](https://arxiv.org/pdf/2607.12197) > Abstract:Development tools report what type an expression has, but not why it has that type\. This paper develops a theory of type slicing: a programmer selects a term, queries any part of its type information, and receives a program slice that is sufficient to reproduce the queried type\. We formulate type slicing for bidirectional type systems, where synthesis slices explain the type a term synthesises and analysis slices explain the type expected by its surrounding context\. The theory applies to any bidirectional system equipped with precision orders on types and terms satisfying a downwards static graduality property\. We develop the metatheory over a core calculus with holes, products, sums, and explicit polymorphism, based on the Hazelnut and marked lambda calculi\. We prove that every query has a minimal slice and that refining a query monotonically shrinks its minimal slices\. We then show how to calculate these slices both exactly and approximately\. Finally, integrating type slicing with error marking theory extends these results to arbitrary ill\-typed programs, so a single mechanism explains both types and type errors in complete, incomplete, and erroneous code\. The metatheory is mechanised in Agda, and a linear\-time approximation of type slicing is implemented for the Hazel programming environment\. ## Submission history From: Max Carroll \[[view email](https://arxiv.org/show-email/9b84bb16/2607.12197)\] **\[v1\]**Mon, 13 Jul 2026 22:53:56 UTC \(445 KB\)
Similar Articles
Unexpected (to me) behaviour in Lisp sub-typing
The article explores unexpected behavior in Common Lisp's SBCL where array sub-typing works for integer types but fails for constrained types like (unsigned-byte 16), attributed to compiler optimizations and upgraded array element types.
Demystifying Type (and some Un-Paradoxing)
The article argues that type theory adds unnecessary complexity to programming language foundations and proposes a simpler view based on relational membership.
Type Inference (Part 1)
A tutorial on type inference covering the Damas-Hindley-Milner type system, unification, and related concepts, with OCaml code examples.
Record type inference for dummies
The article explains the basics of type inference for anonymous records in statically typed languages, using type theory notation and Haskell as the implementation language.
Mechanized type inference for record concatenation
This post mechanizes Mitchell Wand's 1991 type inference algorithm for biased record concatenation, providing declarative and algorithmic semantics and a Haskell reference implementation to advance type checking for Nix and other languages.