3 ms·
It only seems not-hard for people that already understand them. Here's where the post shows just how simple monads can be. > A monad is a data type (e.g. int)
by recursive 7y ago
It only seems not-hard for people that already understand them. Here's where the post shows just how simple monads can be.
> A monad is a data type (e.g. int) that encapsulates some control flow (e.g. try/catch).
But... I'm already lost. How would an integer "encapsulate" control flow? Like different integer values would represent different errors that could occur? Or you could use integers as a representation for a language that has try/catch as a feature? Even in this simplest case, if you don't already grok monads, it's somehow not illuminating for me. YMMV
- setr 7y agothat's just poor wording -- the first example wasn't supposed to be linked to the second example; A better sentence is probably A monad is a datatype (e.g. Either<T,U>) that encapsulates some control flow (e.g. if T != null return T else U) if I understand it correctly