4 ms·
What really made monads click for me is when I read Monads for Go Programmers [0], drawing a comparison between pointers and functors: > We can think of a func
by kortex 6y ago
What really made monads click for me is when I read Monads for Go Programmers [0], drawing a comparison between pointers and functors:
> We can think of a functor as a container, which contains one type of item.
...
> A pointer: *T is a container that may be empty or contain one item;
Despite that comparison probably making seasoned FPers groan, that was a big clicking moment for me.
Thinking along the lines of nullary-function:pointer::return:dereference, frames Linus' abstraction in an interesting light. You're manipulating the "function which yields the struct", not the struct itself. In fact it looks much closer to a map than the cs101 blurb in that now all nodes can be treated symmetrically.
[0] - https://awalterschulze.github.io/blog/post/monads-for-goprogrammers/ https://awalterschulze.github.io/blog/post/monads-for-goprog...