liveBook · Manning

Program hole

As explained in Type-Driven Development with Idris

A program hole is a placeholder for an unfinished expression that can be filled in later.

A program hole is a typed gap in an unfinished definition. Idris can type-check a program containing holes and report what type each missing part must have; the gap itself has no definition. section 1.4.4

Ask for the missing type

If putStrLn needs a String but you have a Char, write putStrLn (?convert 'x'). Inspecting convert reveals the required type Char -> String; cast is one way to fill the hole. section 1.4.4

*Hello> :t greeting
--------------------------------------
greeting : String

The REPL type query shows how to ask Idris what type a named hole must have. section 1.4.4

Holes also help repair code after a type changes: a temporary conversion hole can expose the required type. In a proof about vector reversal, a hole reveals a helper function’s type and lets the proof details be separated from the computation. section 6.3.3 section 8.2.4

How Type-Driven Development with Idris covers it

How deep it goes
Works from hole syntax through REPL type inspection and proof delegation, but leaves type conversions for later treatment.
Examples
Uses a Char-to-String conversion, a schema-refined data store, and a vector-reversal proof helper.
What it assumes
Builds from a simple Idris program and teaches hole syntax and type inspection before using holes in dependent-type code.
What you can do after
Apply it via Idris’s REPL to inspect hole types and guide a missing definition or proof helper.
How it connects
Connects holes to type checking, type-driven development, dependent types, and equality proofs.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Type-Driven Development with Idris. The section links point to the parts of the book it draws on.