Bidirectional Type Slicing

Curated from Lobsters

If you work with statically typed languages, you likely encounter opaque compiler errors that force you to guess which variable or function signature is causing a mismatch. This paper tackles that friction by introducing "type slicing," a method that isolates the exact code fragments responsible for a specific type inference. Rather than dumping the entire program context, it generates a minimal, well-formed snippet that reproduces the queried type behavior. For teams using bidirectional type systems, this is particularly relevant because it clarifies how type checking flows between synthesis and checking modes. The practical value here lies in reducing the cognitive load during debugging. When a type error occurs, you can request a slice to see precisely which sub-term dictates the final type, rather than manually tracing dependencies through complex generic code. This turns a vague inference problem into a targeted inspection task. Takeaway: Integrate type-slicing queries into your IDE or debugging workflow to replace manual type-tracing with precise, minimal code excerpts that explain inference results.

Abstract: Development tools report what type an expression has, but not why it has that type.

— Lobsters

Read the full article on Lobsters →