4 ms·
I, too, have tried to figure out what exactly are monads, and have come away even more confused than I was before.
by askonomm 5y ago
I, too, have tried to figure out what exactly are monads, and have come away even more confused than I was before.
- tester756 5y agoI've heard that dividing e.g 1 by 0 in Excel feels like a monad it's either value or dividing by 0 error :)
- exdsq 5y agoYou know how some functions return a value or an error? Imagine trying to compose several of those functions, passing the value into the next function or handling it’s error. That ends up with a lot of boilerplate. The first time I wrote a Monad was because of this issue. Wrapping this series of function calls in a Monad allows you to write something that reduces that boilerplate by handling the errors of any functions within it, so you can compose them like you’d want How do you handle state in a language like Haskell that doesn’t have mutable state? You pass a data value between functions keeping track of everything, as an extra argument. Imagine the boilerplate of that! Every function suddenly needs an extra argument for Data, regardless of if it needs it, to keep it around. The State Monad deals with that boilerplate.