hemanth / functional-programming-jargon

Jargon from the functional programming world in simple terms!
http://git.io/fp-jargons
MIT License
18.59k stars 1.02k forks source link

Add real world examples and alternative names #119

Closed stereobooster closed 3 years ago

stereobooster commented 8 years ago

Add examples from real world examples.

For example section on monads. Alternative name for chain is flatMap (or flat_map or flatmap). Real world example is streams for instance in highland.

For example section on functors. Real world example: of course Array. But also Streams and Promises. In Promises map is called then.

I believe this can be helpful.

jethrolarson commented 7 years ago

I didn't want to have to explain a bunch of types that aren't built into JavaScript.

Promise.then is actually both the map and flatmap interface which I think makes using it for the explanation confusing

jethrolarson commented 7 years ago

There is a section on Maybe which has chain/flatmap used. Maybe it's worth linking from the monad section

stereobooster commented 7 years ago

Promise.then is actually both the map and flatmap interface which I think makes using it for the explanation confusing

I didn't know that. Worth to mention that fact.

When onFulfilled returns promise (generally "thenable" object) then then works as flatMap, If returned value is not promise then it works as map.

Links: https://promisesaplus.com/, https://gist.github.com/briancavalier/3296186

jethrolarson commented 7 years ago

We've added the name aliases for chain. I'm not comfortable saying that then is equivalent to map. I think we should add a section on Future/Promise/Task to explain the functor aspects of those types.