4 ms·
A “type that wraps another type” describes some monads like List or Maybe but not other monads like the IO monad. A monad is a type which support a particular
by bazoom42 2y ago
A “type that wraps another type” describes some monads like List or Maybe but not other monads like the IO monad.
A monad is a type which support a particular pattern of function chaining. But the caining will have semantics which depend on the particular monad type, so it is difficult coming up with a metaphor which apply to all monads.
- jpc0 2y agoThe IO monad, just like the state monad is still just a type wrapping another thing... In those cases, it is wrapping side-effects. But I don't agree that a burrito effectively represents a monad purely because as you tried to allude to, a monad is not just about the fact that it is a wrapped time but about what functions are available to it. Imagine a list with no map, is it really a monad? https://swlaschin.gitbooks.io/fsharpforfunandprofit/content/posts/elevated-world-7.html https://swlaschin.gitbooks.io/fsharpforfunandprofit/content/... That whole series is a great breakdown of functors and monads that really opened my eyes. This is near the end but that also means all the links are available.
- bazoom42 2y ago> The IO monad, just like the state monad is still just a type wrapping another thing... In those cases, it is wrapping side-effects. Side effects are not a type though. The “type wrapping another type” in the parent refers to List T and Maybe T where T is the wrapped type. But with IO you can have IO String or IO () representing operations with side-effects, so the analogy breaks down. A common problem with half-baked monad explanations is they generalize from one or two monads and then create an analogy which breaks down for other common monads.