More from Stephen Diehl
The Internet Is Kind of a Predatory Cesspit Now I’m a kid of the 90s, and I still remember the early internet. It was slow, ugly, unreliable, and full of cranks, a strange world of wheezing dial-up modems, Usenet flamewars, <marquee> tags, and dancing babies. It was also stubbornly alive and human. People built websites about Babylon 5, model rockets, train timetables, shareware, and whatever else had colonised their minds. Most of it had no business model. That was the literal point. The web felt like a public square assembled by obsessive amateurs. None of this was entirely innocent. There were scams, viruses, Nazis, pornography, and chain emails from deposed Nigerian princes. But then predation moved from the periphery to the centre. It used to be an abuse of the network. Now it is the network’s organising principle. The scammer once had to find a victim. The platform now finds one, profiles the weakness, optimises the pitch, processes the payment, and recommends the next scam. What was once an aberration has become the norm. The modern internet is now a highly optimised machine for detecting human vulnerability, amplifying it, and placing a payment link beside it. Any insecurity can become a commercial niche, including the desire to escape commercial life itself. There is always a course, a newsletter, a private community, or a referral code waiting at the end of the funnel. The bleak part is not that grifters exist. Every society has hucksters. It is that much of the population has been conscripted into the downline. Ordinary people now spend their lives promoting investments they barely understand, products that do not work, and political claims they have never examined. Many earn nothing. They are unpaid distributors for someone farther up the pyramid. The consumer, salesman, and product have collapsed into the same exhausted person. People increasingly behave like addicts because addiction is the business model. The feed supplies alternating doses of outrage, fear, envy, lust, and hope. Each feeling arrives with something to buy. People doomscroll until they acquire the anxiety that the next influencer will monetise. Then they purchase a bet, a coin, a supplement, a course, or an enemy. Finally, they repost the pitch. Consumption becomes distribution. The mark becomes the salesman. This is an industrial system for manufacturing weakness at scale. A legitimate business can survive a satisfied customer. A grift cannot. It needs the customer frightened, aggrieved, lonely, sick, or greedy forever. When I started writing about cryptocurrency in 2020, I still carried a naive assumption about the size of this economy. I thought people were generally decent and the grifter class was a small pool of degenerates with rotten moral character, preying on those made vulnerable by the material conditions of our time. I was very wrong. The grift economy is massive. More disturbing still, it is participatory. A large and growing share of the population now appears willing to devote every waking hour to fleecing their fellow man as a career choice. They stream, post, recruit, promote, refer, astroturf, and close. They turn every friendship into a lead and every conversation into a qualifying call. They do not clock out because the market follows them into bed. The smartphone is a shop counter that sleeps beside their head. Obviously most of these people are not succeeding. The maths simply can never work out. That is part of the trick. The aspiring influencer with forty-seven followers is not an entrepreneur in any meaningful sense. He is free labour for the platform and cheap distribution for the person selling him the dream. The affiliate marketer buys a course about affiliate marketing, then recovers the cost by selling the same course to the next affiliate marketer. The life coach coaches new life coaches. The dropshipper sells tutorials to failed dropshippers. The pyramid is social before it is financial. Everyone stands on someone else while insisting they are about to escape. This arrangement blurs the useful moral distinction between predator and prey. Many online grifters are themselves marks. They believe the rubbish they sell because belief makes the selling bearable. They have sunk money, time, identity, and public dignity into the scheme. Admitting the product is worthless would mean admitting that years of their life were worthless too. It is psychologically cheaper to recruit another victim. The fraud sustains the faith, and the faith sustains the fraud. A normal trade ends when a need is satiated. You need a chair. Someone sells you a chair. You sit down and stop thinking about chairs. However, an online grift can never satiate. It must preserve the need that feeds it. The grievance merchant cannot resolve your grievance. The wellness influencer cannot let you feel well. The trading guru cannot let you become financially secure. The manosphere podcaster cannot let young men become calm, loved, and socially competent. Satisfaction is churn. Misery is recurring revenue. The platforms did not invent fear, greed, loneliness, or status anxiety. They industrialised their extraction. Their recommendation systems are vast reinforcement-learning loops that continuously experiment on human weakness. Each objective is a moving composite of high-dimensional signals for attention, retention, and conversion, dispersed across models, metrics, tests, and feedback systems. The subject cannot see the experiment. The operator cannot fully explain it. The regulator can barely comprehend it. The loop knows only that one stimulus keeps a person scrolling while another lets them leave. Calm accuracy loses. Threat, transgression, humiliation, and impossible promises win. The resulting social damage appears nowhere in the objective function. It arrives as an externality. This creates a brutal selection environment. The honest financial adviser explains diversification and gets twelve views. The crypto lunatic predicts a thousandfold return and gets twelve million. The physician says a chronic condition requires careful management. The wellness crank says seed oils are poisoning your soul. The historian describes an ambiguous event with contingent causes. The political influencer identifies a secret cabal and gives you the address of a pizza parlour. One of these people has the better business model. It is not the one burdened by reality. The system is dopaminergic in the most banal and mechanical sense. It runs on anticipation, uncertainty, and variable reward. The next refresh might bring approval, outrage, profit, or vindication. Usually it brings nothing, which makes the next refresh more urgent. Social media fused the Skinner box with the commission structure. The addict is handed a referral code and told he is now a small business owner. Crypto has become the subject of my verbal ire so often because it is the apotheosis of the grift economy. It takes alienation, precarity, gambling addiction, technological mystification, and a thick slurry of libertarian derp, then synthesises them into the ultimate predatory investment product. Crypto also perfected the recursive structure of the modern online grift. Promotion creates price movement. Price movement is presented as proof of adoption. That proof recruits new buyers. Their money creates more price movement. Every participant has a direct financial incentive to become a publicist for his own position. The asset comes with its own volunteer propaganda network. It is a pyramid scheme with a podcast department. Much to my dismay, the rest of the internet has learned the same lesson. The cheapest product is empty promises untethered to reality. The most scalable labour force is the addict. The best marketing conceals itself inside identity. Sell people a worldview, and they will advertise it for free because criticism of the product now feels like criticism of the self. Language models will make this cheaper and worse. The cost of producing plausible lies has been driven to precisely zero. One person can generate a landfill of articles, videos, testimonials, investment analysis, and synthetic experts before breakfast. The grift no longer needs conviction, charisma, or even a pulse. It needs a language model, an affiliate account, and access to a population whose critical faculties have been sandblasted by twenty years of algorithmic media. There is a temptation to regard the people caught in this machine with simple contempt. Some deserve it. A person who knowingly ruins strangers for commission has made a moral choice. But contempt is not an analysis. Precarity supplies the recruits. Alienation supplies the audience. The collapse of stable work, affordable housing, local institutions, and plausible routes to material security is what makes the pitch of the grift economy so seductive. The grift offers agency where ordinary life offers delay. It offers community where society offers isolation. It offers a jackpot where work offers a performance review and another year of rent increases. Then it metabolises those injuries into new injuries. The lonely man buys a doctrine that makes him intolerable to women. The indebted worker gambles his remaining savings on a crypto token. The frightened patient abandons medicine for supplements. The politically powerless person spends fourteen hours a day screaming at strangers while the people with power quietly cut his wages and public services. The promised escape reproduces the condition that made escape desirable. It is a desperately sad way to live. There is no craft in it, no solidarity, and no completion. No compassion or joy. Every relationship becomes an audience. Every interest just becomes grist for the content mill. Every conviction becomes a content strategy. The grifter can never rest because absence kills engagement. The mark can never rest because the next post might contain the secret. Both wake to the same notifications, trapped on a dopamine treadmill driven by opaque algorithms that can never slow down. The worst advice from the 90s, “just say no,” starts to look less stupid when our greatest technical innovation learns to turn distress into inventory. Disconnection is not Luddism in that environment. It is the refusal to mistake a predatory system for a social world. Complete disconnection is nearly impossible. Modern life no longer permits it. But an appliance is used for a bounded purpose and then put away. Emails, train times, articles, and files all have endpoints. Infinite feeds of drivel do not. They carry the casino into bed and let an opaque RL loop select the emotions that arrive before breakfast. The internet is indisputably an inhuman place. Not because it contains no humans. Billions of us are in here, screaming frantically at each other while feeling utterly alone. It is inhuman because the systems governing it are utterly alien algorithms that cannot recognise human ends. They recognise engagement, conversion, retention, and growth. Grief is a market segment. Loneliness is a targeting signal. Friendship is a retention mechanism. Political conviction is ad inventory. Nothing can simply matter. It must perform. Life inside this environment means adopting its categories. Thoughts are assessed by their reach, experiences by their shareability, and people by their usefulness to an identity. A person becomes legible to the machine by becoming less legible to himself. Eventually the system no longer needs to impose its values. Its subjects carry them in their pockets and enforce them on their own minds. The physical world is not pure. It contains salesmen, casinos, demagogues, fanatics, and bores. It also contains stubborn limits. A conversation ends. A pub closes. A book runs out of pages. Your friend gets tired of hearing you talk and tells you to shut up. Reality supplies friction, and friction is one of the few remaining defences against appetite without limit. We are not going back to the early internet. Nor should we romanticise it. The old web had plenty of sewage. What it also had was space beyond the market. A person could make something without becoming a brand. A conversation could end without a conversion. A community could exist without turning its members into marks for an investment scheme. The question is not whether the internet contains useful things. It does. The question is whether human existence should be organised around alien and inhuman objective functions no human chose and nobody can inspect or understand. An RL loop can optimise engagement, retention, and conversion. It cannot tell us what a human life is for. The final grift is letting the loop decide what your life should be.
Prism: An Impure Functional Language With Typed Effects This is going to be a very nerdy post so bear with me. Here is a function. Read it the way you would read any other function, and then tell me its type. fn fib(n) = var a := 0 var b := 1 repeat(n) fn let t = a + b a := b b := t a That is a mutable loop. There is a var, there is assignment, there is a temporary so the swap does not eat itself. It is, line for line, the fib you would write in Python after deciding that recursion was a young person's game. Its type is Int -> Int, it is functional but in place. There is no effect type even though the function has effects, because the effects are not observable from outside the function. As far as anyone calling it is concerned, this function is pure. It mutates two variables in place and then, before the door closes behind it, sweeps up the evidence and leaves no fingerprints. And the compiler does it all for you. It's the code you would write in Python with types you get from OCaml and no monads. This is Prism, a proof of concept functional compiler I've been working on for the last three years, built around modeling effects with modern types inspired by the intellectual lineage of OCaml 5, Haskell and Koka. The big idea of the last five or six years of functional programming is that effects are real, effects are fine, and the interesting question is not how to avoid them but how to put them in the type system and then optimize them until they cost nothing. Effects Are Interfaces The one idea you need is the algebraic effect handler. An effect declares operations; a handler gives them meaning. Here is a producer that yields a sequence and has no idea who is listening: effect Gen { ctl yield(Int) : Unit } fn produce(n) : !{Gen} Unit = if n == 0 then () else yield(n) produce(n - 1) The !{Gen} in the type is the function confessing, in writing, that it performs the yield operation and someone upstream had better deal with it. Now we hand the same producer to two different handlers: fn total(n) = handle produce(n) with yield(v, k) => v + k(()) return r => 0 fn count(n) = handle produce(n) with yield(v, k) => 1 + k(()) return r => 0 The k is the continuation, the rest of the computation, reified as an ordinary value you can hold in your hand. total resumes it and adds; count resumes it and counts. A handler can ignore k entirely (that is an exception), call it once (that is state, or a generator), or call it many times. This last one is the move that makes algebraic effects more than sugar. Here a handler finds Pythagorean triples by resuming the same continuation once per candidate, which is to say it explores a whole search tree using nothing but straight-line code and a handler that says "yes, and also try the other branch": effect Amb { ctl choose(Int) : Int, ctl reject(Unit) : Int } fn triple(n) : !{Amb} Int = let a = choose(n) let b = choose(n) let c = choose(n) if a > 0 && b > 0 && a <= b && a * a + b * b == c * c then a * 10000 + b * 100 + c else reject(()) fn solutions(n) = handle triple(n) with choose(m, k) => flatten(map(\(i) -> k(i), range(0, m))) reject(u, k) => Nil return r => Cons(r, Nil) fn main() = let sols = solutions(14) println(length(sols)) println(sum(sols)) choose(n) offers a value in 0..n-1 and reject() prunes a dead branch, and because the handler resumes k once for every candidate, triple reads like a function that just picks three numbers. If you have used OCaml 5 this will feel familiar, except OCaml keeps its effects out of the types, so you find out about an unhandled one at runtime, in production, on a Friday. If you have used Haskell this will also feel familiar, except in Haskell you would be assembling a monad transformer stack, lifting each operation through every layer by hand, and explaining to a junior colleague that a monad is just a monoid in the category of endofunctors, what's the problem. Prism's effects are row polymorphic. They union structurally across calls. There is nothing to stack and nothing to lift, because there is no tower, only a set. One Trick, Five Ways Once effects are first class, a remarkable number of ideas from the last thirty years of language design turn out to be unified under the same mechanism: Exceptions are a handler that throws away the continuation. A clause marked final ctl discards k, so its body's value becomes the handler's result and the rest of the computation is simply abandoned. No Result threading, no ? confetti up the call stack, just direct-style code that stops: fn safe_grade(n) = handle grade(n) with final ctl abort(msg) => concat("invalid: ", msg) return r => r And because an exception is just a label in the effect row, you get extensible exceptions for free. Each distinct failure is its own operation, so the row in a function's type spells out exactly which exceptions can escape it, the way !{Gen} spells out that it yields. There is no root Exception class to inherit from and no hierarchy to edit; a new exception is just a new label. They union structurally across calls, so a function that can abort and a function that can timeout compose into one whose row carries both. Handling one of them discharges its label and leaves the rest in the row, which means partial recovery is something the type system tracks rather than something you promise in a comment: effect Abort { ctl abort(String) : Unit } effect Timeout { ctl timeout(Int) : Unit } -- fetch's row spells out both failures it can raise fn fetch(id) : !{Abort, Timeout} String = if id < 0 then abort("bad id") if id > 99 then timeout(id) "ok" -- discharge Timeout with a fallback; Abort still escapes fn with_default(id) : !{Abort} String = handle fetch(id) with final ctl timeout(_) => "cached" return r => r The handler peels Timeout off, so with_default is left carrying exactly !{Abort}, no more and no less. Java's checked exceptions wanted to be this and could not, because they were welded to the class hierarchy instead of being an open, structural set. Generators and streams are a producer that performs emit, transformers that catch it and re-emit, and a consumer that folds. A pipeline is handlers nested around one producer, which means there is no intermediate list, by construction: srange(1, n).smap(square).skeep(even).stake(5).ssum() Stopping early, the stake(5), is just a handler dropping a continuation once it has what it needs. Cancellation produces garbage, and that garbage is reclaimed at a statically known point with no collector involved, which is the good part we will come back to. The stream library was inspired by Haskell's pipes and conduit. Lenses are not a library anymore they are language-integrated. They are record-update paths plus the memory model. Given three nested record types, one path expression reaches arbitrarily deep and sets several fields at once: type Vec2 = Vec2 { x: Int, y: Int } type Player = Player { pos: Vec2, hp: Int } type Game = Game { player: Player, score: Int } deriving (Lens) let g2 = { g | player.pos.x = 30, player.hp = 95, score = 110 } That rebuilds the spine of the nested record, and when the value is uniquely owned, each rebuild reuses the cell it just took apart, so a functional update compiles to a pointer write. No optic types are allocated, nothing is composed at runtime, the path is just addresses. The entire optics ecosystem, the van Laarhoven encoding, the profunctor zoo, the operators that look like a cat walked across the keyboard, all of it collapses here into one syntax rule and a memory discipline. And when you genuinely need to pass an accessor around, deriving (Lens) hands you score_of and with_score as ordinary functions: let g3 = with_score(g2, 200) -- score_of(g3) == 200 They are boring functions, which is the highest compliment in functional programming! Mutable state is the var from the opening. Each var desugars to a private effect with get and set operations, discharged by a handler installed at the end of its block. The state never escapes, an analysis rejects any closure that would try to smuggle it out, and the enclosing function keeps its empty row. This is the loop you would write in Python with the signature you would want in Haskell and none of the State monad plumbing in between. Failure is the most fun, because it is functional logic programming sneaking in through the effect row. An anonymous Fail effect makes "this expression might not produce a value" a thing the type system already knows how to talk about. fail() performs it, guard(cond) performs it when a check is false, and the consumers read like a wish list: let port = cfg.at_map("port") ?? cfg.at_map("https") ?? 443 let off = customer?.tier?.discount ?? 0 let bill = [item for item in sof(cart), if prices.at_map(item) > 4] ?? falls back when the left side fails. ?. chains through options and short-circuits. The comprehension guard prunes elements that fail instead of crashing. And because var is itself just handler sugar, an entire block can be transactional: transact snapshots every live variable, runs the body in a failure context, and rolls everything back if it fails, so an overdrawn account behaves as if the purchase never happened. transact balance := balance - price guard(balance >= 0) balance else 0 Five features. One underlying mechanism, viewed through a five dimensional prism. And that lovely idea is the namesake! Modern Types So far we haven't seen a lot of type signatures which is the point, most of the time you can write down quasi-Python-looking code and inference is decidable and predictable via the usual complete-and-easy Dunfield-Krishnaswami algorithm. You annotate only where you genuinely cross into higher-rank territory, which is rare, and the algorithm meets you exactly at that boundary. A function can demand a genuinely polymorphic argument, declared with a forall on the binder, and then use it at several types in one body: fn pick(g : forall a. (a) -> a) : Int = if g(true) then g(10) else g(20) fn main() = println(pick(\(x) -> x)) g is forced to be polymorphic, so pick may apply it to a Bool and an Int in the same breath, which is why main can only hand it the identity function and not, say, a number. A Hindley-Milner core would have unified a with Bool on the first call and rejected the second; here the forall survives into the argument. Ad-hoc polymorphism is type classes, but Lean-flavored: instances are named values, not anonymous magic resolved by global coherence. You write given Ord(a) to ask for a dictionary, and you can name exactly which one you want at the call site when more than one is in scope: instance ordDesc : Ord(Int) { fn cmp(x, y) = int_cmp(y, x) } sort_by_ord(xs) -- the default Ord(Int) sort_by_ord[ordDesc](xs) -- this one, reversed The instances you do not care about, you do not write. One deriving clause off a type declaration synthesizes the boring ones, and the field accessors too: type Vec2 = Vec2 { x: Int, y: Int } deriving (Eq, Ord, Show, Lens) with_x(v, 7) -- a derived setter, and FBIP-reused when v is unique Classes also feed pattern matching, which is the part that tends to make PL people sit up. A pattern can name a class method as its view, and then that one pattern deconstructs every type with an instance, dispatched by dictionary exactly like a method call: pattern First(n) for Peek = view peek fn head_or(x : c, d : Int) : Int given Peek(c) = match x of First(n) => n _ => d First(n) matches a Box, a Range, or anything else that is Peek, and head_or is generic over all of them at once. The pattern is as polymorphic as the function around it. Some ad-hoc polymorphism does not even need a class. show is type-directed: the compiler infers the static type of its argument and synthesizes a structural printer from the real constructor names, recursing into fields, with no instance to write and no runtime type dispatch (the printer is monomorphized from the static type, so it never reads a runtime tag to decide how to print): show(42) -- "42" show([1, 2, 3]) -- "[1, 2, 3]" show((7, false)) -- "(7, false)" show(Node(Leaf, 1, Leaf)) -- "Node(Leaf, 1, Leaf)" And the third axis is the one the rest of the post is really about: the same row variable that makes effects composable makes them polymorphic. Here is a higher-order function that calls its argument twice and adds the results. The argument's effect row is a variable e, which is to say twice does not care what f does, only that it returns an Int: fn twice(f : (Unit) -> Int ! {| e}) = f(()) + f(()) The {| e} is "this row, and whatever else." Each call site unifies e with the actual row of the thunk it passes, and that is the whole trick: one definition serves a pure argument, an effectful one, and an effectful one of a completely different effect, with no overloads and no wrapping. fn pure_use() = twice() fn(u) 21 Here e unifies with the empty row {}. No effect is performed, so no handler is needed, and the result is just 42. Now force the same twice to carry an effect through: fn tick_use() = handle twice(\(u) -> tick(())) with tick(u, k) => \(n) -> k(n)(n + 1) return r => \(n) -> r The thunk performs Tick, so e unifies with {Tick}, and the surrounding handle discharges exactly that one label. Swap in a thunk that performs Say instead and e becomes {Say}; twice itself never changed. A handler only ever names the labels it wants, and e quietly carries everything else along, which is what lets these functions compose without a transformer stack to thread them through. The same machinery, three times: one definition, abstracted over types, over dictionaries, and over effects. Zero-cost Abstractions At this point the cynical hater reader (hi Hacker News!) is thinking the thing most cynics think about elegant abstractions, which is: sure, but what does it actually cost. Algebraic effects have a reputation. The textbook implementation reifies your whole computation into a free monad, a tree of "here is an operation, and here is a function for what to do with its result," and then an interpreter walks that tree allocating a small cell at every single operation. It is beautiful and it is a heap allocation per yield. Prism does not do that on the path that matters. The fast path is evidence passing in the Koka lineage, with my own deviations noted where they matter: instead of reifying the computation and reaching for the handler, it carries the active handler clause to each operation site as an ordinary parameter. A do op becomes a direct call. So we don't need a tree, or interpreter loop, or cell. The only allocation is one closure per handler when you install it, which is O(handlers), not O(operations). You can perform yield a billion times under a handler that was allocated exactly once. The free monad is still in the building, because some patterns genuinely need it (a computation that escapes into a data structure, a truly multishot resumption, a masked handler). But it is the fallback, not the default, and the compiler proves which one you are in. Now point this at the stream pipeline from earlier: for n in srange(1, 11).smap(square).skeep(even) do print(n) An interprocedural flow analysis works out, across function boundaries, exactly which effect evidence each producer and transformer needs, and threads it through. The whole chain lowers to a single loop with zero intermediate lists and zero per-operation cells. This is essentially Haskell-like stream fusion, but the thing Haskell achieves with rewrite rules that fire only if you hold your imports correctly and the wind is blowing precisely the right direction while Mercury is in retrograde, and what Rust achieves by monomorphizing iterator adapters into one another at the type level. Here it falls out of the effect compiler, because once emit is a direct call to a known clause, inlining the clause into the producer is just inlining. The cleanup, meanwhile, is the good part promised earlier, and it is not a garbage collector. Prism uses Perceus reference counting: every heap cell is freed at a statically known point, deterministically, with no pauses and no tracing. And then the clever idea is that we have frame-limited reuse, where a cell you just deconstructed in a pattern match gets handed straight back to the constructor on the other side of the arrow, so map over a uniquely owned list mutates the list in place while remaining, on paper, a pure function returning a new one. The lens update compiling to a pointer write is this same machinery. So is the loop in fib not allocating. Purity and mutation turn out to be the same thing viewed from different ends of an ownership analysis, which is either a deep idea about the nature of computation or quite banal, and I'm not quite sure which. The Runtime & LLVM Backend If Perceus reference counting sounds familiar, it should: it is the same memory discipline Lean 4 runs on, and for the same reason, a dependently typed proof assistant cannot afford GC pauses any more than a game loop can. Lean compiles to C and links a little runtime that does the counting. Prism does the structurally identical thing, except it emits LLVM IR (through inkwell) and, for the same program, a text MLIR module, and then hands the result to clang to link against one hand-written C runtime, prism_rt.c, about a thousand lines. That runtime is deliberately tiny. A heap cell is four-plus words, { refcount, tag, arity, fields... }, and the whole file is the allocator, the rc_inc/rc_dec pair that the compiler sprinkles through the code, the in-place reuse allocator that the FBIP pass targets, and the bignum and string primitives. There is no collector thread, no card table, no safepoints, nothing that runs when your code is not running. The reference counting is not a service the runtime provides at runtime; it is code the compiler already wrote into your program, and the C file is just where the four or five operations it calls happen to live. It links against plain libc malloc by default (there is an opt-in mimalloc knob for benchmarking, but the whole thesis is "do not allocate," and a fast allocator only hides the allocations you failed to eliminate). A live-cell oracle asserts the heap balances to zero at exit, so "garbage free" is a property the test suite checks rather than a thing the README asserts. Runs In Browser through WASM The same interpreter that serves as the differential oracle compiles to wasm, so there is a playground where you can type Prism and run it without installing anything. It runs the program in a worker, and the buttons next to it will dump the inferred type signatures (effect rows and all) and the lowered core IR, so you can watch a var loop or a stream pipeline turn into the thing it actually compiles to. Every example in this post is in the dropdown. Poke at the effect rows; they are the whole point. The full source, the Lean model, and the C runtime all live in the prism repository on GitHub. Nerd Stuff For completeness, if you have read this far you have clearly made some very questionable life choices (hi fellow traveller!) so here's the PL nerd stuff: Type inference is the usual SOTA bidirectional and higher-rank, the complete-and-easy Dunfield-Krishnaswami algorithm, so rank-N polymorphism works without you annotating your way out of it. Typeclasses with Lean-style named instances (instance ordInt : Ord(Int)), explicit override (sort_by_ord[ordRev](xs)), and deriving (Eq, Ord, Show). A mostly OCaml-ish-shaped surface syntax : layout blocks, dot chains (xs.over(f).keep(g).sum()), with sugar for continuation-passing code, string interpolation, effect row aliases. Deep recursion runs in constant stack, both natively (tail calls, and tail recursion modulo a constructor) and in the interpreter (it is essentially a more advanced version of the old CEK machine, so nothing in your program can blow the host stack). And, for the genuinely afflicted, the full intellectual lineage. Obviously standing on the work of many FP giants, but the ones that are most directly inspired Prism's design are: The core IR is call-by-push-value (Levy, Call-by-Push-Value: A Functional/Imperative Synthesis, 2001), whose split between values and computations is the thing that makes both the effect lowering and the reference counting analysis clean rather than heroic. The fast effect path is evidence passing (Xie and Leijen, Generalized Evidence Passing for Effect Handlers, ICFP 2021; Effect Handlers, Evidently, ICFP 2020), the same compilation strategy Koka uses, with the free-monad encoding (Swierstra's Data Types a la Carte, and Kiselyov's extensible effects) kept only as the fallback. The memory model is Perceus (Reinking, Xie, de Moura, Leijen, Perceus: Garbage Free Reference Counting with Reuse, PLDI 2021) plus frame-limited reuse (Lorenzen and Leijen, Reference Counting with Frame-Limited Reuse, ICFP 2021) and fully-in-place programming (Lorenzen, Leijen, Swierstra, FP^2: Fully in-Place Functional Programming, ICFP 2023), which is also what turns the lens sugar into pointer writes. The effect rows are row polymorphism with scoped labels (Wand 1987; Leijen, Extensible Records with Scoped Labels, 2005; Type Directed Compilation of Row-Typed Algebraic Effects, POPL 2017), and handlers themselves are Plotkin and Pretnar (Handlers of Algebraic Effects, ESOP 2009) by way of Eff and Koka. Pattern matching compiles to decision trees with a usefulness matrix for exhaustiveness (Maranget, Compiling Pattern Matching to Good Decision Trees, 2008; Warnings for Pattern Matching, 2007), and the pattern forms are view patterns crossed with GHC's Pattern Synonyms (2016). The failure layer is the Verse calculus (Augustsson, Peyton Jones, Steele, Sweeney, et al., The Verse Calculus, ICFP 2023), recovered entirely from final ctl handlers with no new core. A subset of the core is mirrored in a Lean 4 model (models/Prism.lean) with a machine-checked determinism theorem, and the three backends are held byte-identical by treating the interpreter as a differential oracle. The thesis, if a toy project gets to have one, is that "purely functional" was always a slightly defensive name for a good idea. The good idea is that effects should be visible, typed, and composable. You do not need to forbid them to get that; you need to track them. And once you are tracking them honestly, the compiler has enough information to make them free, which is the part the purity narrative never promised you, because it was too busy not making eye contact with the IO monad. This compiler is essentially my love letter to the old 2010-20s era of functional programming which was a much simpler and happier time (or maybe that's just the rose-tinted glasses of youth in the ZIRP era). This compiler is a toy, it is for all intents and purposes useless except maybe as kind of a piece of art from a bygone time before the Transformer-era of programming. The world we're headed to doesn't really have a place for this kind of thing anymore. We're increasingly headed to a world in which maximally probabilistic hilariously-uninteresting Typescript increasingly runs most of the world as we babysit these token extruders while the economy and markets become increasingly automated by agents. While this makes me kind of sad, it doesn't mean we still can't build this kind of thing just for fun and that's what I did here. Maybe the future of functional programming languages is increasingly niche-but-economically-irrelevant and becomes more like a hobby pursuit for the few of us who still love it for the intellectual beauty of the underlying ideas. So I built it anyways, and it runs, and it was a blast to build. And just maybe that's enough, in this brave new world of software.
Book Review: On the Calculation of Volume Solvej Balle's On the Calculation of Volume is a planned septology about a Danish antiquarian book dealer who falls out of time, and the first five volumes are one of the most original and brilliant literary projects I've read in years. The premise is the one you have seen a hundred times. The protagonist, Tara Selter, wakes up on the eighteenth of November. The day passes. She goes to sleep. She wakes up. It is the eighteenth of November. Her husband Thomas, who lives with her in a stone house in northern France, has no memory of the previous iteration. She does. So it's basically like Groundhog Day, except the protagonist is a soft-spoken Danish bookseller, the comedy has been carefully removed, and the camera has been turned around to face the inside of the day itself. I read all five over a week in San Sebastian, sitting in the bright Atlantic light of the Basque coast while reading about a woman who can't leave a single grey rainy day in northern France, and the books were only better for the contrast. Mild spoiler warning: I'll describe the shape of each book but not its turns. Skip to the bottom if you want to come to the cycle clean. The first volume is the small one, around two hundred pages, minimalist in both plot and prose. The minimalism is the point. Tara has returned to Clairon-sous-Bois from a book fair in Paris with a small burn on her hand from a hotel heater and a Roman sestertius in her bag, and we meet her on day one hundred and twenty-two of the loop. By then she has the day memorized to the second. The blackbird sings at the same instant every morning. The cup is where she left it. Thomas, beautifully indifferent to the cosmological catastrophe he is sleeping through, asks her about her trip. She tells him. He listens. He has listened a hundred and twenty-two times. There is something sisyphean about a marriage where one of you has to begin the conversation again from scratch every morning. The writing here is the kind of plain prose that takes a whole career to learn how to write. Short sentences. Present tense. Almost no metaphor. A naturalist's field notebook, kept by someone who has begun to understand that the field is closing in. Barbara J. Haveland's English translation is so unobtrusive you forget the book was written in another language. Volume I is a phenomenology textbook in the disguise of a novel, and the disguise is so good that the textbook keeps surprising you with feeling. A year passes inside the day, and in the second volume Tara goes traveling. She has worked out by then that the eighteenth restarts wherever she happens to be sleeping, so she can take the loop with her. She rides trains. She crosses Europe. She follows snow up to Norway and crepuscular light down to the south, anything that might serve as evidence of the season she has been denied. The trick of Volume II is that it is a travelogue turned inside out. The world is supposed to be the still backdrop against which the traveler moves. Here the traveler is the still one. She is the same November eighteenth wherever she goes. It is the world that keeps shifting under her, a palimpsest written and overwritten on the same Wednesday, and the shifts are rendered so attentively that the book becomes a slow, hallucinatory survey of how light behaves in different latitudes when the same day is happening to it. The sestertius travels with her, opening into a lovely tangent about the Roman empire and the routes its money once took, and by the end of the book Tara's senses have sharpened to a pitch where the prose itself begins to breathe differently. The world, she writes, is whispering in a new language. Her husband, who appears in this volume mostly as someone she telephones from foreign hotels, has begun to feel the strain of being loved by a woman who is aging at a rate his calendar refuses to acknowledge. And then, in the third volume, the project does something nobody saw coming. Tara meets someone else. His name is Henry Dale. He is a sociologist. He has been inside the day longer than she has, and he has a young son in America whom he visits every loop at his ex-wife's house. Imagine being four years old and meeting your father every morning, knowing he is the same and knowing also that he carries with him a freight of time you cannot see. The book never over-stresses the heartbreak, letting it sit the way it lets everything sit. Tara and Henry try to figure out what they are to each other. The volume is, in part, about how dignified people behave when the universe has made them, against their will, into a liminal society of two. Then Olga arrives, with her plan to reorganize the loop into a fairer society. Then Ralf, with his plan to spend each iteration of the day stopping every preventable accident on the planet. The four of them have nothing in common except the day, and the novel is too honest to pretend that the day is enough. The marriage with Thomas has by now become the book's quietest engine of dread. Tara is older. Thomas is not. Every morning he wakes up younger than the woman who has come home to him. By Volume IV they have moved into a big house outside Bremen, and the four have become fifty. Volume IV does something I have rarely seen at this scale in serious literary fiction. The singular voice breaks. The careful "I" of the first three books gradually, and then unmistakably, becomes a "we," and the book begins to read like extended meeting minutes from the most interesting commune ever convened. The residents argue about everything. They argue about what to call themselves. They argue about whether the day should be measured from sunrise or from the moment of arrival. They argue about food, because food consumed inside the loop is gone from the loop forever, and a population of fifty is a meaningful pull on a finite breakfast. They argue about healthcare in a world where every wound resets at midnight. They argue, in other words, about the load-bearing architecture of any society, and they argue at a pace and an articulacy that is recognizably the kind of conversation that only happens when people have nothing to lose and everything to figure out. The whole project is apophatic, an attempt to build a vocabulary for their condition by exhaustively naming what it is not. The volume keeps the metaphysics inside the kitchen. The questions about language and identity never float free of the bread. Someone is always doing the dishes. The book ends on a hinge I will not describe, except to say that it earns the turn. Volume V is the settling. The exhilaration of Volume IV gives way to something stranger and gentler, the texture of a second life slowly making itself plausible. The community has habits now. Some of the loopers have begun to write. Some have begun to teach. Some have figured out, the way people figure out anything important, that you can build a tolerable existence on a foundation of repetition if you stop arguing with the foundation. New arrivals appear at the door, and the work of welcoming them, of explaining the day to a stranger who has just discovered they are inside it, becomes a kind of vocation. The central insight of the cycle, after five books, clarifies itself. The project is the great novel of dailiness. Joyce gave us one Dublin day at six hundred pages of close attention. The series is the same Wednesday written eleven hundred times over, and somehow still not done. Not a novel that contains daily life among its themes. A novel about the daily as such. The eighteenth of November is the prosaic distilled into philosophy. Mornings. Bread. Light at a window. The same conversation begun gently for the thousandth time. What a life is, these five volumes suggest, when you take away the future and you take away the past, and you are left with the present examined at the resolution of a Vermeer. Two more volumes are coming. The engine, after five books, shows no sign of fatigue, and the project keeps getting larger by getting smaller. I recommend these books to anyone who keeps a notebook and wants a beautiful, quiet, understated meditation on life wrapped in metaphysical curios. Anyone who has written down what the morning light looked like on a particular Wednesday and felt slightly embarrassed about doing it. Anyone whose work involves going back to the same thing over and over until it finally starts to make sense. If you have ever caught yourself cataloging the way your kitchen table looks at six in the morning and felt something that was neither boredom nor revelation but a third thing, calmer than both, then Solvej Balle has written the books you did not know were possible, and she has written five of them and is still going. They are, sentence by sentence, some of the most beautiful prose being published anywhere right now. They are also, taken together, a serious and unembarrassed meditation on time, on selfhood, on what a person is when she is no longer accumulating history, and on what a marriage is when only one of you is aging into it. Tara cannot leave the eighteenth of November. None of us can leave today either. Eternal recurrence treats this as a test. The absurd treats it as a climb. Balle treats it as a practice. The prosaic, attended to, is the depth. The repetition, accepted, is the meaning. The measure of a life is one you would say yes to twice, and these books leave you wondering whether her one day, lived a billion times, is really so different from our own lives.
Book Review: What We Can Know Ian McEwan has described What We Can Know as "science fiction without the science," which is both a fair warning and a precise advertisement. The novel is set in 2119. Rising seas and a cascade of nuclear wars (including a misfired Russian warhead in the Atlantic and something called the Third Sino-American War) have halved the world's population and turned Britain into a sleepy archipelago of mountain peaks connected by ferries and funiculars. The Bodleian Library has been relocated to Snowdonia. The global currency is the Nigerian naira. The United States is a lawless territory of feuding warlords. People navigate between islands in electric canoes. Oxford's Sheldonian Theatre is underwater. And the people of this era look back at the early twenty-first century with the specific mixture of envy and contempt that we reserve for civilizations that had everything and squandered it. They call our time "the Derangement." They study us the way we study the late Romans: as a case study in spectacular, voluntary decline. McEwan builds this world with the offhand confidence of someone who has thought about it for a very long time and decided that understatement is more frightening than spectacle. He never dwells on the catastrophe. He simply places you in its aftermath and lets you feel the weight of what is missing. The future is rendered in small, devastating details: a literature professor teaching to near-empty rooms, "a relic of the humanities in a world that no longer values them, a poor cousin to the water scientists." The only growth industries are data recovery and atmospheric management. Meanwhile, future scholars study the period 1990-2030 under the rubric "90.30 literature," and their verdict on us is brutal: "They were big and brave, superb scholars and scientists, musicians, actors and athletes, and they were idiots who were throwing it all away." Into this world McEwan places Tom Metcalfe, a literature professor who has devoted his career to reconstructing a lost poem. The poem, "A Corona for Vivien," was written by the celebrated (and, as we will learn, monstrous) poet Francis Blundy. A corona is a chain of linked sonnets where each begins with the final line of the previous one and the sequence closes when the first line returns, forming a circle. Blundy read it aloud at his wife Vivien's birthday dinner in 2014. The few who heard it called it the capstone of his career, comparable to The Waste Land. He then destroyed all drafts, making the single vellum copy a unique gift. The poem was never seen again. Tom has access to the complete digital archive of the early twenty-first century. Quantum computing broke all the cryptography of our era, cracking open every encrypted data silo, every private message, every corporate vault. The result is total transparency: every email, every text message, every shopping list, every social media post, all of it preserved in servers in New Lagos, all of it legible to anyone with a library card. He can reconstruct the dinner party guest by guest, message by message. And here is the novel's central, quietly devastating paradox: having all the data changes nothing. The fundamental truth about the poem, about the people who made and destroyed it, remains hidden. As Tom observes with the wry frustration of a man drowning in information: "If you want your secrets kept, whisper them into the ear of your dearest, most trusted friend. Do not trust the keyboard and screen. If you do, we'll know everything." Everything, that is, except what matters. This is McEwan's epistemological argument, and he pursues it with the rigor of a philosopher and the patience of a novelist who has been thinking about narrative and knowledge for fifty years. The past, he argues, is always a reconstruction. "Memory is a sponge. It soaks up material from other times, other places and leaks it all over the moment in question." A journal "fixes events like beads on a string," but lived experience refuses to be sequential. The imagined, he writes, "lords it over the actual, no paradox or mystery there." What we can know, it turns out, is bounded on all sides by what we want to believe, what we can remember, and what we are willing to see. The novel's second half detonates everything the first half has built. Vivien's own memoir surfaces, and in it we learn that Francis Blundy, revered poet, climate change denier, man of letters compared to Heaney and Larkin, murdered Vivien's first husband. Percy Greene, a luthier with early-onset Alzheimer's, was pushed down the stairs and finished with a mallet. Blundy framed it as mercy. He then absorbed the dead man's suffering into his poetry, transmuting private horror into public art. The famous "Corona for Vivien" was, in coded form, a confession of this crime and an aestheticization of the grief it produced. Vivien, recognizing the poem as a beautiful counterfeit that stole her real memories and repackaged them as literary accomplishment, fed the vellum into a dairy stove. The poem burned. She then buried her prose account, ensuring that the truth, rather than the artful lie, would reach the future. McEwan has always been drawn to people who believe their own brilliance exempts them from ordinary moral constraints, and Blundy is the fullest realization of this obsession. The novel asks whether great art can launder terrible acts and has the courage to leave the question genuinely open. When Vivien destroys the poem, you feel the loss and the justice simultaneously, and that simultaneity is the point. The beauty of the work and the cruelty of the man who made it occupy the same space, and McEwan will not let you collapse one into the other. If you have read Atonement, you will recognize the engine: nested narratives, the question of who controls the story, the devastation that arrives when the reader's reconstruction collides with the truth. But where Atonement asked whether fiction could redeem guilt, What We Can Know goes further. It suggests that the possibility of redemption was always a comfortable fiction, and that what remains is persistence. A colleague's pregnancy near the end is described as "the next link in the chain of futility and care," with the emphasis falling equally on both nouns. You keep going because the work of reconstruction (of poems, of knowledge, of a livable world) has its own dignity regardless of outcome. The novel is dense, and it is about more things than any single review can cover. It is about the humanities and whether they survive catastrophe (they do, barely, and in diminished form, and the novel argues this diminished survival is still worth something). It is about climate change as a moral solvent that dissolves familiar categories into entropy. It is about the specific longing of looking backward at a world you never knew, for which McEwan observes we need a word "beyond nostalgia, which pines for what was once known." It is about the relationship between scholarship and love, between archival precision and emotional truth, between the living and the dead. McEwan's prose has loosened with age. The earlier novels were watchmaker-precise, sometimes to the point of airlessness. Here the sentences breathe. There is humor (dry, English, arriving when you least expect it) and a warmth toward the characters that his earlier work sometimes withheld. The New York Times called it "the best thing McEwan has written in ages." The Scotsman called it his masterpiece. I think they are both right. It is the rare novel that will make you feel as deeply as it makes you think, and the rarer one still that earns the right to that ambition. McEwan has said that his goal was "to let the past, present and future address each other across the barriers of time." He has succeeded. If you are reading this in 2026, the novel's future scholars have already rendered their verdict on you. The fact that you are reading a book review rather than doomscrolling may, by the standards of 2119, constitute a minor act of civilization. Make the most of it.
Book Review: Piranesi Susanna Clarke's Piranesi is a book about a man who lives in a House. The House has an infinite number of marble halls. Ocean tides flood the lower floors. Clouds drift through the upper ones. Thousands of statues stand in the middle halls, each one unique, depicting figures from mythology and daily life and everything in between. The narrator maps the halls, tracks the tides, catches fish to eat, and keeps meticulous journals. He calls himself Piranesi. He believes he is one of two living people in the entire world. He is happy. If this sounds like a fairy tale, it reads like one too. The prose is plain, earnest, and completely without irony, delivered in the cadence of a naturalist's field journal. Piranesi describes extraordinary things (tidal waves crashing through marble vestibules, clouds forming indoors, skeletons of people who died in halls nobody else has visited) with the calm precision of someone recording the migratory patterns of local birds. The effect is hypnotic. You settle into the rhythm of his observations and begin to see the House the way he sees it: as a complete and beautiful world, sufficient unto itself. And then, very gradually, the floor drops out. Clarke structures the novel so that you, the reader, understand what is happening to Piranesi before he does. You notice the gaps in his journals. You catch the references to things that should not exist in an infinite marble labyrinth (shoes, a wristwatch, the word "Manchester"). You begin to assemble the real story from fragments, exactly the way an archaeologist assembles a pot from shards. The dramatic irony is sustained for the entire book, and it is devastating, because Piranesi's innocence is so total and so genuine that watching it dissolve feels like a small crime. The philosophical engine of the novel is a question about identity and memory. Piranesi's real name, real history, and real knowledge have been taken from him. What remains is a person who is good, curious, and attentive to the world he inhabits. Clarke asks whether this person, built from the ruins of another person, is less real than the original. Her answer is generous and quietly radical: the self that pays attention, that cares for the dead, that feels gratitude for the beauty of statues, has its own integrity. Memory loss produced this person, but the person is real. The name, of course, comes from Giovanni Battista Piranesi, the eighteenth-century Italian artist whose "Carceri d'Invenzione" (Imaginary Prisons) depict vast, impossible architectural spaces filled with staircases and arches that lead nowhere. The etchings are claustrophobic despite their scale. Infinite space rendered as confinement. Clarke takes the Carceri and makes them habitable, even lovely. Her narrator finds the House beautiful because he has no memory of anything else, no basis for comparison, and therefore no basis for complaint. A prison the prisoner loves. It is the novel's most quietly terrifying idea, and Clarke handles it with the lightest possible touch, trusting you to feel the weight yourself. What makes Piranesi exceptional, and the reason I think it will last, is the quality of attention it models. Piranesi's journals are an extended practice of noticing. He names every statue. He tracks every tide. He remembers every skeleton. In a literary landscape saturated with cleverness, irony, and narrative pyrotechnics, Clarke wrote a book whose central argument is that paying attention to the world you are in, really paying attention, with care and without cynicism, is itself a moral act. It is a book about the radical sufficiency of presence. If you have ever caught yourself looking at something ordinary (a building, a riverbank, a piece of code) and felt the brief, embarrassing conviction that it was beautiful and that the beauty mattered, Clarke has written the novel about that feeling. It is 250 pages. You will read it in a day. You will think about the statues for weeks. Clarke published it sixteen years after Jonathan Strange & Mr Norrell, which was 800 pages of baroque alternate history. Piranesi is the opposite: everything stripped to the bone, every sentence load-bearing. If Jonathan Strange was a cathedral, Piranesi is a single perfectly proportioned room. Personally, I prefer the room.
More in startups
It’s very tempting to imagine that AI turns everyone into a tool-builder - now everyone can just ask the model to make the software they need, and apps as we know them are dead. I think that misunderstands how most people think and where software actually comes from, and more importantly, it isn’t a path to change how companies actually work.
Those with the most to lose are often the least likely to take big swings