Arnaud Spiwack wanted to represent sheaves in Haskell, but the textbook definition brought a practical problem: sieves contain many redundant representations of the same matching information, and their dependent pullback construction was too much dependent typing for Haskell. The obvious approach—translate the definition literally—would make illegal states representable and bury the program in irrelevant data.

He first built a concrete example around arithmetic expressions. A presheaf could pull values back along expressions, but the desired conditional operation required a sheaf to glue two branches over a Boolean cover. The implementation therefore made gluing an explicit type-class operation, then generalized it into a Site whose typed Cover and Gen families describe which pieces can be assembled.

The typed site removes the pullback-sieve burden: glue can operate at any arrow, and generators need not be represented as actual arrows. Products, exponentials, Yoneda embeddings, coproducts, and recursive lists can then be defined in the same style. Sheafify acts as a free sheaf construction by storing gluing operations rather than evaluating them prematurely, while PFun carries the variance needed for exponentials.

The result is a demonstration repository and a Haskell-shaped implementation of the abstract idea, not a claim that every mathematical detail disappears. Spiwack explicitly leaves fixed points unresolved, but the project converts a definition that was too loose for the language into typed, operational building blocks and makes the remaining unknown precise.

Represent covers as types, then glue explicitly

Literal sieves encode redundant matching-family values and allow states that should be impossible.

The pullback sieve needed for exponentials demands dependent typing beyond what the Haskell implementation could comfortably express.

Typed covers and generators keep the valid gluing interface small while removing irrelevant representations.

Sheafify stores gluing syntax, allowing free constructions such as coproducts and recursive lists without running the operations early.

Making fixed points an explicit unresolved boundary prevents the implementation from pretending to solve what it does not yet know.

When a formal definition creates illegal states and impossible dependent typing, encode valid covers in types and expose only executable gluing operations. Keep free constructions for composition.

The project produced a demonstration repository with concrete and abstract Site/Sheaf instances, plus a clearer boundary around what the encoding can and cannot express. Fixed points remain unresolved, but the typed-cover approach makes sheaf operations usable in Haskell without importing the full weight of sieve-dependent machinery.

FOLLOW THE EVIDENCE

The sources

  1. Subcanonical coverage ncatlab.org
  2. Pursuing Shtuck inria.hal.science