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.

Adventures in Category Theory – The algebra of types (2018)

66 pointsby mathematicallyover 3 years ago

2 comments

brainwipeover 3 years ago
Great article, here&#x27;s the first in the series: <a href="https:&#x2F;&#x2F;miklos-martin.github.io&#x2F;learn&#x2F;fp&#x2F;category-theory&#x2F;2018&#x2F;01&#x2F;29&#x2F;adventures-in-category-theory-introduction.html" rel="nofollow">https:&#x2F;&#x2F;miklos-martin.github.io&#x2F;learn&#x2F;fp&#x2F;category-theory&#x2F;201...</a>
Zababaover 3 years ago
&gt; If our objects are sets (as they are in the category of types and functions)<p>And from the previous article:<p>&gt; What I do love about category theory is that it is not some framework, or design pattern, or best practice that somebody came up with empirically because it helped them solve their problem, but it has strong mathematical foundations. It always adds up, things click smoothly, and it is just so satisfying and fun to experience this.<p>I was thinking about that in the context of nominal and structural typing. From my (limited) understanding, set theory is equivalent to structural typing. That would mean the following:<p><pre><code> type point = { x: int; y: int } type my_point = { x: int; y: int } let example (p: point) = p.x + p.y let po: point = { x = 5; y = 6 } let my_po: my_point = { x = 1; y = 2 } example po &#x2F;&#x2F; =&gt; 11 example my_po &#x2F;&#x2F; =&gt; type error </code></pre> should typecheck, as point and my_point are exactly the same from a &quot;set&quot; point of view. But they don&#x27;t. It&#x27;s like naming the record made them different types even if they are structurally the same. So this is something I don&#x27;t understand. I feel like I&#x27;m missing something, but I don&#x27;t know what.
评论 #28928701 未加载
评论 #28928857 未加载
评论 #28929315 未加载
评论 #28929340 未加载
评论 #28929033 未加载