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...
Cofounded Host Collective (DiscountASP.net). Cofounded Player Axis (Social Gaming). Computer Scientist and Technology Evangelist with 20+ years of experience with JavaScript!
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>