SF LEAN · ALOK SINGH · JULY 21, 2026
record → function → error → array → InfoView
Follow along
alok.github.io/talks/lean-unfair-advantage/
The Haskell server still runs. Its share of the system is shrinking.
For a conventional application: use Python.
The provocation: go farther than Haskell. Use Lean.
ROUTINE LEAN
records and functions
Array, Except, loops, IO
#check, #eval, InfoView
DOMAIN TYPES
MV R3 .full
multiplication computes result parity
the renderer receives a plain projection
Lean is officially described as both a programming language and proof assistant · lean-lang.org
structure Vec3 where
x : Float
y : Float
z : Float
structure R3Grades where
scalar : Float
vector : Vec3
bivectorNormal : Vec3
pseudoscalar : Float
abbrev Field3 (M : Type) := Vec3 → M
structure Sample3 where
position : Vec3
value : R3Grades
fieldAt : Float → Vec3 → MV R3 .fullMV R3 p → R3GradesHover the ordinary view types here. In Cursor, hover fieldAt for the one dependent type used by the computation.
structure PlanarGrid where
xCount : Nat
yCount : Nat
def sampleCount (grid : PlanarGrid) : Except String Nat := do
if grid.xCount < 2 then
throw "xCount must be at least 2"
return grid.xCount * grid.yCount
#evalExcept.ok 9 sampleCount { xCount := 3, yCount := 3 }
Except.ok 9#evalExcept.error "xCount must be at least 2" sampleCount { xCount := 1, yCount := 3 }
Except.error "xCount must be at least 2"
This slide is a Lean file. Verso type-checked the code while building the deck.
PlanarGrid → function → Except String (Array Sample)
Switch to Cursor · OrdinaryProgrammingDemo.lean
import
MV R3 .fullthis field has the R3 metric and may contain every gradeMV R3 .eventhe rotor can contain only even grades.even * .full = .fullmultiplication computes the result parityR3Grades.ofMVone explicit boundary produces plain view data