TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

The algebra and calculus of algebraic data types

170 pointsby alex_hirnerover 6 years ago

10 comments

vajrabumover 6 years ago
That&#x27;s fun and a bit surprising, but maybe it shouldn&#x27;t be. I&#x27;m reminded that Dana Scott with Christopher Strachey showed that by using lattices or complete partial orders with a bit of topology to model graphs of possible computations of a program you could, just as in analysis, define least upper and lower bounds and a notion of continuity to derive a construction of limit for a computation which is analogous to a limit in analysis. They called this model a domain. That bit of of math is the basis of denotational semantics of programming languages and is necessary because sets are largely sufficient as the basis for algebra and analysis but not for programs which have evils like partial functions, side effects and variable assignment. I believe that Christopher Strachey with Scott also introduced the formal notions of sum, product and recusive types. They also showed how definitions or models of recursive types and functions could be well founded through their construction of limits on domains. An early tech report on it can be found here:<p><a href="https:&#x2F;&#x2F;www.cs.ox.ac.uk&#x2F;files&#x2F;3228&#x2F;PRG06.pdf" rel="nofollow">https:&#x2F;&#x2F;www.cs.ox.ac.uk&#x2F;files&#x2F;3228&#x2F;PRG06.pdf</a><p>and here&#x27;s a more recent free book from David Schmidt on the topic:<p><a href="http:&#x2F;&#x2F;people.cs.ksu.edu&#x2F;~schmidt&#x2F;text&#x2F;DenSem-full-book.pdf" rel="nofollow">http:&#x2F;&#x2F;people.cs.ksu.edu&#x2F;~schmidt&#x2F;text&#x2F;DenSem-full-book.pdf</a>
评论 #17944136 未加载
评论 #17958496 未加载
vignesh_mover 6 years ago
This is almost identical to the study of combinatorial species (<a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Combinatorial_species" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Combinatorial_species</a>)
carapaceover 6 years ago
If you like this you&#x27;ll want to look at &quot;semiring programming&quot; (just search on that phrase) and Categorical Programming, e.g.: &quot;Compiling to categories&quot; Conal Elliott <a href="http:&#x2F;&#x2F;conal.net&#x2F;papers&#x2F;compiling-to-categories&#x2F;" rel="nofollow">http:&#x2F;&#x2F;conal.net&#x2F;papers&#x2F;compiling-to-categories&#x2F;</a>
评论 #18051246 未加载
rfwover 6 years ago
Nat = Nat + 1 does end up being meaningful: since ultimately the numbers that fall out (e.g. Bool = 2) end up describing the sizes of sets, an interpretation of Nat is some infinite cardinal (aleph-null), which is the size of the set of natural numbers.
评论 #17950001 未加载
arithmaover 6 years ago
A cool aspect is how this algebra&#x2F;calculus sheds light that maps(&#x2F;dictionary&#x2F;associative-arrays) have an equivalent cardinality to functions and that they are in many ways the same.
评论 #17944532 未加载
benrbrayover 6 years ago
I once tried to take the Taylor series idea further and define the &quot;cosine&quot; of a type as the Taylor expansion of cos(x), but didn&#x27;t get anywhere with it.<p>Can you do anything else weird with ADTs?
评论 #17945373 未加载
Sharlinover 6 years ago
One thing I’ve been wondering is how to interpret the function types `Void -&gt; a` and `a -&gt; Void`, where Void is the uninhabited type (unique up to isomorphism). The number of inhabitants of those types should be |a|^0=1 and 0^|a|=0, respectively, but what does that mean? In real world, function(s) of type a-&gt;Void certainly exist, such functions being those that diverge (loop forever or halt via some non-local means).
评论 #17943383 未加载
评论 #17943359 未加载
评论 #17942939 未加载
评论 #17942800 未加载
trompover 6 years ago
Very neat insights into data type differentiation! Minor nitpick: the article uses<p><pre><code> data Unit = Unit </code></pre> but the Haskell standard Prelude already has the empty tuple type (), with single element (), functioning as the standard unit type.
hyperpalliumover 6 years ago
Does distributivity hold? <i>a x (b + c)</i> = <i>a x b + a x c</i>
评论 #17943813 未加载
评论 #17943792 未加载
评论 #17944263 未加载
andrzejszover 6 years ago
What happened to Code Words that are not new issues?