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. 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?? 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?

Follow

@monorail as far as the purractical considerations go, yes, you get it, that’s what you use a monad fur

the thing to observe that you didn’t mention is that the interface to this abstraction/contextualization is extremely general, and exactly reusable line-fur-line with other abstractions, which is neat

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.