News for hackers. Stuff that matters.
Re:Functors, Applicatives, and Monads by magicalhippo on Sunday March 30, 2025 @05:54PM (#43528024)
If I give you a function "f(x) := 3 * x", is it really that useful to talk about it as a container of the natural numbers?

The reverse though is useful, a container looks like a function that takes one or more indices and returns a value or element.

Re:Functors, Applicatives, and Monads by rebeccaskinner on Sunday March 30, 2025 @06:50PM (#43528540)
I think that understanding the (moral) equivalence is useful in both directions. In particular, I think helping people understand the "function-as-container" analogy is a useful way for people to understand pure functions- another thing that's conceptually simple but a lot of people struggle to really wrap their mind around it.
Re:Functors, Applicatives, and Monads by magicalhippo on Sunday March 30, 2025 @07:36PM (#43528925)
Personally I would say it muddies the water for me, as "container" has strong connotations in other directions.

But then I've never thought the concept of a pure function to be particularly difficult, despite growing up on procedural languages.

It's other bits that I struggle with when it comes to functional programming.