• 0 Posts
  • 17 Comments
Joined 1 year ago
cake
Cake day: June 2nd, 2023

help-circle
  • Thank you, that’s an excellent read! This reminds me of the “expected value of perfect information” - sometimes it is worthwhile to answer a question, and sometimes it isn’t. Every once in a while I find myself in an engineering call discussing a minor problem, and I run the numbers to see if the change we are discussing is even worth talking about. One time the combined salaries of the people on the call had already outpaced the cost savings of the change over the next 10 years. We quickly stopped that discussion lol















  • Any form of bread with a filling, generally assembled cold

    But, dare I say, does that not make a ravioli a sandwich? A poptart? Mayhaps even … Lasagna?

    Ah, you proclaim! But those are cooked further!

    But so too is a grilled cheese! And a patty melt!

    Where will the madness end?



  • Of course!

    In other words though, for those just starting their monad journey:

    An endofunctor is a box. If you have a box of soup, and a function to turn soup into nuts, you can probably turn the box of soup into a box of nuts. You don’t have to write a new function for this, if the box can take your existing function and “apply” it to its contents.

    Arrays are endofunctors, because they hold things, and you can use Array.map to turn an array of X into an array of Y.

    Monoids are things you can add together. Integer plus integer equals integer, so ints are monoids. String plus string (concatenation) equals a longer string, so strings are monoids. Grocery lists are monoids.

    Arrays are monoids!

    Arrays are both endofunctors and monoids, so for everyone except category theory purists, they are monads.

    Javascript promises hold things, and you can transform their contents with .then - so they are endofunctors. You can “add them together” with Promise.all (returning a new promise), so they are monoids. They are both monoids and endofunctors, so they are monads.

    I’ve just upset all the category theorists, but in the context of programming, that’s all it is. It’s surprisingly simple once you get it, it’s just complicated names for simple features.