Some people have said a Promise is a Monad. Others have said a Promise is not a Monad. They are both wrong... and they are both right.
By the ti...
For further actions, you may consider blocking this person and/or reporting abuse
Thanks! Nice examples.
Just one suggestion: under title "Back to the Monad" you explain flatMap, but not Monad, and then you just say: "We have covered Functors and Monads".
It left me a bit confused until I read further.
I miss one sentence like "A Monad is similar to a Functor, but is Flat Mappable between Categories." in the "Back to the Monad" section.
Thanks for the feedback. I have added a couple of sentences a little closer to the
flatMap
example to hopefully add some clarity to this:Hope that helps!
Cheers!
Found a mistake:
[1, 2, 3].map(x => x + 1) //=> [2, 4, 6]
Correct result:
[2, 3, 4]
Correct function for the result above:
[1, 2, 3].map(x => x * 2) //=> [2, 4, 6]
Great catch! I was so used to typing
x => x * 2
that I didn't even notice I was usingx => x + 1
.Article has been corrected.
Cheers!
Great examples! The funny thing is, everything I read something about Monads, I think „now I understood it“. Two days later, I’ve can’t explain it anymore. Maybe I’ll have to explain it to someone first to remember it.
One question though: Isn’t map usually used to return a different type (at least in statically typed languages)? So I wonder why it returns itself again with a new value...
The type in question here is
Array
. So when you map on an array you still get an array.For example, you might map a Number to a String, but you'd still be in an Array:
Array<number> -> Array<string>
Promises could've been purely monadic if not for some ignorant dudes...
github.com/promises-aplus/promises...
I love Feynman and your explanation!
Thanks!
Feynman has a video: Physics is fun to imagine or something like that. It's one of my favorite videos to rewatch over and over :)
Thanks for de recommendation I love that guy. The BBC documentary about Feynman work/life is good also.
For sure. I can't get enough. Even have a few of his books at home. He does a great job of explaining complex terms for the Lay person.
You know, as long as Monad tutorials go, this is pretty cool and simple, would you mine if I write a translation in Spanish? Of course I will reference your work.
I am happy you found it useful :)
All translations welcome! Link it back here too, I am curious to see the translation :)
Cheers!