bidirectional-type-checking

Implement bidirectional type checking algorithms for compilers and interpreters.

17|2|Updated Feb 16, 2026
One-click install
npx skills add https://github.com/rainoftime/pl-skills --skill bidirectional-type-checking
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bidirectional-type-checking
Source: https://github.com/rainoftime/pl-skills/tree/main/bidirectional-type-checking
Command: npx skills add https://github.com/rainoftime/pl-skills --skill bidirectional-type-checking

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires type-inference-engine, simply-typed-lambda-calculus.

What problem does it solve?

This Skill helps implement type checkers that provide better local error messages and support advanced type system features by leveraging bidirectional algorithms.

Core Features & Use Cases

  • Mode-Directed Typing: Implements inference and checking modes for precise type analysis.
  • Elaboration: Supports the conversion of surface syntax to a fully typed core language.
  • Use Case: When building a new programming language or enhancing an existing one, use this Skill to create a robust and user-friendly type checker.

Quick Start

Implement the bidirectional typing rules for lambda calculus, distinguishing between inference and checking modes.

Frequently Asked Questions about bidirectional-type-checking

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How does bidirectional type checking improve compiler error messages?

Bidirectional type checking improves compiler error messages by using mode-directed inference and checking to pinpoint exact type mismatches locally. This enables structured error reporting during elaboration from surface syntax to a typed core.

How do I implement bidirectional typing rules for lambda calculus?

To implement bidirectional typing rules for lambda calculus, distinguish between inference and checking modes. This mode-directed approach allows the type checker to synthesize types from expressions or verify expressions against expected types.

What is elaboration from surface syntax to typed core language?

Elaboration is the process of converting untyped surface syntax into a fully typed core language. By using bidirectional type checking, the compiler ensures this conversion is type-safe and generates structured errors for invalid programs.

Do I need expertise in functional programming to use bidirectional type checking?

Yes, implementing bidirectional type checking requires expertise in functional programming and type theory. The algorithm relies on concepts common in languages like Haskell and OCaml to manage mode-directed inference and elaboration.

What is the difference between inference mode and checking mode in type checking?

Inference mode synthesizes a type from an expression, while checking mode verifies an expression against an expected type. Bidirectional type checking alternates between these modes to achieve precise type analysis and better local error reporting.

When should I use bidirectional type checking instead of standard type inference?

Use bidirectional type checking when building a compiler that needs better local error messages and support for advanced type system features. It handles complex rules by combining inference and checking modes during elaboration.