Programs are diagrams. Computation is extension. The compiler fills the horn.
A Kan program is a partial diagram awaiting universal completion.
Most languages ask you to describe every step. Kan begins from what you actually know — some objects, some maps, some constraints — and treats the gaps as opportunities for universal construction.
Every paradigm has one computational act. The lambda calculus has application; logic programming has inference. Kan’s is extension: given a partial diagram, find the canonical object or morphism that completes it. Named for Daniel Kan — whose Kan extension and Kan complex both say the same thing: a partial diagram has a canonical filler.
One sort, one relation, one operation. Cells (objects, morphisms, … as dimensions of one thing), their faces (which let a diagram be partial), and fill — complete a horn. Everything else is derived, and the modality dial decides how strong a completion to demand.
Some filler must exist. This builds the categorical substrate — composition, identities.
The best filler, unique up to isomorphism — a Kan extension. This does the real work: products, limits, colimits, folds.
A recursive datatype is an initial algebra; a fold is the unique homomorphism out
of it — a universal fill. Here an evaluator, written in Kan, compiled to a native binary:
-- expr_eval.kan data Expr { Lit int, Add Expr Expr, Mul Expr Expr } let e = Mul(Add(Lit(2), Lit(3)), Lit(4)) -- (2 + 3) * 4 fold eval : Expr -> int { Lit v = v, Add a b = a + b, Mul a b = a * b } show eval(e)
$ kan build expr_eval.kan -o expr && ./expr
20
The fold lowers to a recursive C function; the binary runs the computation itself.
Phase 1 complete Kan is an early research language — the core is real and runs, the type system and program-completion layers are next.
fill: composition, products, pullbacks, coproducts, folds.kan → C → binary)# requires OCaml + dune and a C compiler git clone https://github.com/jackmitchelwidman/kan cd kan && dune build kan run examples/expr_eval.kan # interpret kan build examples/expr_eval.kan -o expr && ./expr # compile & run
Design doc: README · the surface language, core calculus, and compiler are documented in /docs.