Hacker News new | ask | show | jobs
by aesyondu 1606 days ago
Oh okay. So what I'm understanding from your post is that, a monad is just a way of applying the return value of one function as a parameter for another function.

Sorry if I misunderstood. I've been reading many explanations for monads, but insight seem to elude me.

1 comments

Well, mostly - but I think this wrapping of things is the more important part, allowing us to manipulate the inner things without actually being able to touch those.

For example, mapping some function over a Result type that may or may not have a value in an iterative manner would make me check for the existence of the value, unpack, and apply function. If we have a Monad abstraction then I can just map my function which will be applied in case of a result, or the whole thing will remain None - it is safe either way. And one other useful part is the uniformity of functions working on monads - I can use the same ones for a List, Result, or any similar container, IO, State monads and even Async is a monad.