watching a video about what a monad is because i've never understood them despite trying. they set up this simple toy example to motivate everything and then went "so, where do monads come in? surprise: we just wrote one". screaming and crying and shitting my pants. i was deceived.
(posted it in a reply but: i actually want this link in the OP as well. https://youtu.be/C2w45qRc3aU)
monads spoilers
okay i've read explanations of monads that explained what they're for and didn't get it. and i've read explanations of monads that explained "a monad is just when you have these two functions" and didn't get it. but this video has both "here's what they're for. to accomplish that you just need these two functions" and i think i get it?? https://youtu.be/C2w45qRc3aU
monads spoilers
like "Option is a monad" didn't make sense to me but "Option is a monad, because we take a value and put it in its own little 'Option' ecosystem and pass any transformations we want to do into it, and the case of 'no value' is handled by the inner workings of that ecosystem without any extra work" kind of does
okay i'd like to check my understanding. can someone who actually does understand monads confirm this for me
when you take a value of type T and put it into an Option<T>, you're putting that value into a context that abstracts away some work. you can still do things to the value, but you're doing it via Option, which is what allows it to do that abstraction
and that's what makes Option a monad? that's what a monad is?
pedantry
@monorail the data types are not monads; the data type and the implementations of the wrapper and the runner functions are what constitute a monad. i mention this because i know of two monads on List; similarly, you could feasibly define two very diffurent kinds of monads around lazy evaluation
re: pedantry
@aescling that makes sense but i think that even in an educational context, as long as you're also giving another explanation of what you actually mean, something like "Option is a monad" makes sense to say as a recap
which i think you also believe, hence the cw :P