DEV Community

Discussion on: Functional JavaScript - Functors, Monads, and Promises

Collapse
 
stealthmusic profile image
Jan Wedel

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...

Collapse
 
joelnet profile image
JavaScript Joel

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>