5 ms·
Monads are just function chaining worshiped in the holy language of category theory. You have an array of state, and you can call a method on it that returns a
by danielvf 2y ago
Monads are just function chaining worshiped in the holy language of category theory.
You have an array of state, and you can call a method on it that returns a new array of state, that you can call a method on, that returns a new array of state, etc. And that concept of doing state -> function call -> state is the holy Monad.
A JS pleb would write instead:
burrito = (new Tortilla()).addMeat(Chicken).addMissionBurritoIngredients().holdThe(Cheese)
No one would be confused about what was going on, and it would be basically the same thing.
- FrustratedMonky 2y agoYes. But perhaps a syntax around the type of the return object to match with the next function. While it is just functions. To say, it's just functions all the way down, doesn't help you talk about them. Could say that math is all functions, and having some language to discuss that subject is maybe more the purpose of the monad. Kind of like if you were to say to a math student, just go study functions, no need for any school or language to describe what is happening. But yes, category theory is a bit heavy handed to a programmer just needing to chain some functions. Maybe the problem is such a vast gulf between the junior dev just needing to know how to chain some things, and the category mathematician that has never coded. Yet they are circling around the same subject.