4 ms·
Here’s my monad tutorial for programmers A monad is anything you can flatmap with The monad of list is you flatmap a list on a list and instead of getting a l
by bedobi 5mo ago
Here’s my monad tutorial for programmers
A monad is anything you can flatmap with
The monad of list is you flatmap a list on a list and instead of getting a list of lists, as you would if you just mapped, you get a single flattened list
The monad of Result is you flatmap many function calls (like http requests or whatever) on each other and instead of getting many results, you get a single flattened result
Most of you already know this, without necessarily even knowing what a Monad is
Monad literally just means "one thing" - you take many things, and flatmap them into one
Thanks for attending my ted talk
- throw_await 5mo agoAnd by introducing Monad, we gain the ability to abstract over these things: List, Option, Result, Functions, State, ...
- bedobi 5mo agoyes, which is why Monad should be an interface that types like List, Option, Result etc implement, instead of flatMap being just a random discrete function that exists on random types by accident, with no common abstract link between them Kotlin, Java, basically every other language except Haskell, F# etc didn't get that memo