Get the latest tech news

The algebra and calculus of algebraic data types (2015)


!) of algebraic data types Note: This article assumes some introductory Haskell knowledge. Introduction Just as algebra is fundamental to the whole of mathematics, algebraic data types (ADTs) are fundamental to many common functional programming languages.

They’re the primitives upon which all of our richer data structures are built, including everything from sets, maps, and queues, to bloom filters and neural networks. Some research has been done on deciphering some meaning from this mess, but I can’t use negative and fractional types without adopting the additional language semantics they propose. There are no holes in a constant∂ac=0\partial_a c = 0∂​a​​c=0Sums are straightforward∂∂af(a)+g(a)=∂∂af(a)+∂∂ag(a)\frac{\partial}{\partial a} f(a) + g(a) = \frac{\partial}{\partial a} f(a) + \frac{\partial}{\partial a} g(a)​∂a​​∂​​f(a)+g(a)=​∂a​​∂​​f(a)+​∂a​​∂​​g(a)As are products∂∂af(a)×g(a)=∂∂af(a)×g(a)+f(a)×∂∂ag(a)\frac{\partial}{\partial a} f(a) \times g(a) = \frac{\partial}{\partial a} f(a) \times g(a) + f(a) \times \frac{\partial}{\partial a} g(a)​∂a​​∂​​f(a)×g(a)=​∂a​​∂​​f(a)×g(a)+f(a)×​∂a​​∂​​g(a)The chain rule still applies for composition∂∂a(f∘g)=(∂∂af∘g)×∂∂ag\frac{\partial}{\partial a} \left(f \circ g\right) = \left(\frac{\partial}{\partial a} f \circ g\right) \times \frac{\partial}{\partial a} g​∂a​​∂​​(f∘g)=(​∂a​​∂​​f∘g)×​∂a​​∂​​gLet’s take a moment to marvel at the fact that differentiation, a tool developed by Newton and Leibniz over 300 years ago for physics, has made an unexpected appearance in the most discrete of settings.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Calculus

Calculus

Photo of Algebraic Data Types

Algebraic Data Types

Photo of algebra

algebra

Related news:

News photo

Linear Algebra 101 for AI/ML

News photo

Calculus with Julia

News photo

Algebraic Data Types for C99