by evincarofautumn · 11y ago · 0 comments
Abstract algebra and category theory give you incredibly useful program and API structuring techniques; you can get lots of nice properties for free by following these well-worn existing patterns, even more so than OOP design patterns. We make use of them a lot in Haskell, but they’re basically language-agnostic.
Even simple algebraic manipulations, like noticing that “return” is distributive over a conditional:
if x then return y else return z
return (if x then y else z)
Are very useful for restructuring programs to be more readable.As my former exercise instructor for linear algebra told to the math students at the beginning of the second semester: Those people who have not yet understood that matrices are more than a box of numbers are definitely at the wrong place here.
http://www.haskell.org/haskellwiki/Curry-Howard-Lambek_corre...
It was mind-opening for me to think of types in terms of provability (intuitionistic/constructive logic) rather than truth (classical logic). The only way to prove that a function returning a value of type T actually halts (and therefore does not actually “return” bottom/void) is to run it and obtain that T value, i.e., to find the object that the type claims exists.