hemanth / functional-programming-jargon

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

Functor example does not make any sense #238

Closed alper closed 1 year ago

alper commented 1 year ago

In Functor there's:

const f = x => x + 1
const g = x => x * 2

some(1).map(x => g(f(x))) // = some(3)
some(1).map(f).map(g) // = some(3)

Especially the second but maybe both should by any reasonable intuition be 4?

Take some(1), map it through f, result 2, map it through g, result 4.

If for some reason this is different than reading order, then I would say that that reason is wrong.

Also I can't try this out because there's no REPL anywhere?

CrossEye commented 1 year ago

@alper: You're right. The example is wrong. Care to create a PR to fix it?

marcwrobel commented 1 year ago

Done in #240.