News for hackers. Stuff that matters.
Re:Dualities in Functional Programming by kelseyfrog on Sunday January 26, 2025 @06:50PM (#42835588)
Besides those mentioned in the article, most everything in functional programming has a dual, usually by prefixing "co-". Cofunctor, coapplicative, comonoid, comonad, &c. All things with reversed arrows and varying degrees of usefulness.
Re:Dualities in Functional Programming by cess11 on Monday January 27, 2025 @03:15AM (#42838663)
That looks like category theory rather than functional programming.
Re:Dualities in Functional Programming by klysm on Monday January 27, 2025 @03:24AM (#42838716)
The two are pretty much the same when you get down to it
Re:Dualities in Functional Programming by aleph_minus_one on Monday January 27, 2025 @06:59AM (#42840155)
In my experience, what computer scientists (in particular programming language researchers) consider to be "category theory" is very different from what mathematicians (in particular those working in algebraic geometry, algebraic topology, homological/homotopical algebra, ...) consider to be the important parts of category theory.

In my very biased and unfair perspective, the "computer science perspective" on category theory is rather applying the first 50 introductory pages of a decent textbook about category theory, while for mathematicians, where category theory actually starts to become somewhat interesting is only, say, from page 150 on, when also a lot of additional mathematical concepts that actually motivate (or even necessitate) these much more complicated category theory topics have additionally become introduced.

Re:Dualities in Functional Programming by Cladode on Monday January 27, 2025 @07:41AM (#42840524)
But why is that a problem?

Category theory is an API for mathematics that was developed with specific applications in mind that the API seeks to unify and make easier to think about. Those application domains are algebraic geometry, algebraic topology, homological/homotopical algebra. Every API comes with trade-offs: typically an API makes one domain easier, at the cost of making other domains harder. Example: CSS is Turing complete. And I think CSS is really good at helping with styling webpages. But I would not want to write a compiler is CSS.

Computer scientists, like myself, who read from Page 150 onwards have just found the API stylised for algebraic geometry, algebraic topology, homological/homotopical algebra, ... not that useful, for applications in computer science. Unlike the first 50 pages, which have been very useful. More specifically, we found the cost of using purely categorical APIs not worth the benefits in many application domains. Maybe we are missing something, maybe we overlooked something. But, given the investments since the 1990s of computer science into category theory, I'd like to see more evidence for!

To conclude with a concrete example: why would I write a compiler using an API for homotopical algebra?

Re:Dualities in Functional Programming by cess11 on Monday January 27, 2025 @12:03PM (#42843203)
Who told you that?
Re:Dualities in Functional Programming by klysm on Tuesday January 28, 2025 @08:29AM (#42852055)
Don't think anybody told me that, but I do believe it to be the case
Re:Dualities in Functional Programming by cess11 on Tuesday January 28, 2025 @10:58AM (#42853785)
Why?
Re:Dualities in Functional Programming by klysm on Tuesday January 28, 2025 @04:13PM (#42858101)
Category theory is equivalent to type theory.
Re:Dualities in Functional Programming by iLemming on Friday January 31, 2025 @01:28PM (#42890203)
It's probably more accurate to say that they are complementary rather than equivalent.

- Category theory emphasizes morphisms and composition

- Type theory emphasizes terms and computation

There are important correspondences between them (like the Curry-Howard-Lambek correspondence), but they have different strengths and different ways of expressing concepts.

Sorry, I couldn't resist the temptation of being a pedantic formalist.

Re:Dualities in Functional Programming by iLemming on Friday January 31, 2025 @12:44PM (#42889752)
That's just another path to understanding and gaining practical insights about things. While these mathematical concepts can provide rigorous foundations for understanding software patterns, they're not really essential for applying the practical knowledge of:

- How to handle failures (null vs defaults)

- How to structure APIs (separated vs combined)

- How to organize services (monolith vs microservices)

Most developers already using those category theory concepts without even realizing:

Functor patter - is just mapping over sequences; Applicatives - sequence operations; Monads - promise chaining in JS; Comonads for context management (e.g., with-open db-connection), etc.