首页›Hillel Wayne›文章

A Very Early History of Algebraic Data Types

2025年9月25日

AI 摘要 AI 生成,可能有误

该文章将代数数据类型最早的历史追溯到约翰·麦卡锡(John McCarthy)1961年的论文《计算的一种数学理论基础》,该论文引入了笛卡尔积和“直接并集”,以及它们如同构和分配性等代数性质。随后,作者追溯了这些思想如何通过托尼·霍尔(Tony Hoare)在命令式语言中数据结构方面的工作(“可辨别联合”一词即由此创造)以及罗德·伯斯托尔(Rod Burstall)影响了函数式编程的结构归纳工作而传播开来。最后,作者对兰丁的ISWIM是首个拥有代数数据类型的语言这一普遍说法提出异议,认为它仅仅是一个提案,很可能从未实际定义过和类型。

Been quiet around here! I’ve been putting almost all of my writing time into Logic for Programmers and my whole brain is book-shaped. Trust me, you do not want to read my 2000-word rant on Sphinx post-build LaTeX customization. But I spent the past week in a historical rabbit hole and had to share what I found.

It started with Algebraic [Data] Types are not Scary, Actually. The post covers AlgDTs1 in more detail, but a quick overview is:

Product types are things like (Int, Bool) or Dog(name: str, owner: Person, age: Int). They have a value for each field. Almost all modern languages have product types, usually calling them something like “structs” or “records” or “value object” or whatever.

继续阅读全文

为了尊重作者,这里只展示开头几段。你可以去原文阅读,或者在 HorizonReader 里读:划线做笔记、让 AI 帮忙。

更多来自 Hillel Wayne

A Crash Course in Predicate Logic

AI 摘要This article, adapted from the second chapter of the book Logic for Programmers, is a crash course in formal logic for programmers. It explains predicates as Boolean-returning functions that can be concrete or abstract, uses a CanRunProgram example and truth tables to show how formal logic removes ambiguity from natural-language requirements, and introduces the implication operator (=>) along with sets for constraining predicate inputs.

Logic for Programmers is Now Available

AI 摘要The author announces the release of their book, Logic for Programmers, which took five years to write and teaches working developers the basics of formal logic and its applications, including property-based testing, domain modeling, and logic programming. The book was created because no programmer-focused resources existed for learning these fundamentals, and it requires no math background. Early access buyers can get version 1.0 for free on Leanpub.

Chicago vs New York Pizza is the Wrong Argument

AI 摘要The author, writing for April Cools, argues that the classic 'Chicago vs New York pizza' debate is meaningless because deep dish is a special-occasion food while New York-style pizza is an everyday food, making them poor points of comparison. Instead, they propose comparing New York pizza to the Chicago-style hot dog as role-equivalent iconic local foods, ultimately conceding that NYP wins for ease of home preparation while praising the Chicago dog as a superior hot dog. The piece closes as a celebration of other Chicago specialties like Italian beef, the jibarito, and flaming saganaki.

Some Silly Z3 Scripts I Wrote

AI 摘要The author shares a collection of discarded Z3 example scripts (written with Python bindings) produced while working on their book 'Logic for Programmers', explaining that Z3 is an SMT solver that finds values satisfying mathematical and programming constraints. The examples range from solving equation systems and math puzzles about equal sums and products, to optimizing annual bank deposits, reverse engineering a pseudorandom number generator's parameters, proving theorems by checking for counterexamples, and maximizing stock trade profit. Along the way, the article demonstrates Z3 features like the Optimize solver, the theory of arrays, and constraint checking with additional temporary constraints.

Gamer Games for Non-Gamers

AI 摘要Written as part of the 'April Cools' tradition, this article recommends video games that are accessible to non-gamers, using criteria such as running on ordinary hardware, requiring no prior gaming knowledge, being culturally meaningful, and being games the author has personally seen non-gamers enjoy. The author details four picks—Baba is You, Stardew Valley, The Case of the Golden Idol, and Balatro—explaining each game's mechanics, appeal, and historical context within its genre. The piece aims to lower the barrier to entry into gaming, which despite being a half-trillion-dollar industry remains surprisingly niche compared to movies or music.