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

Array.prototype.map() in javascript doesn't preserves integrity #93

Closed jonasporto closed 7 years ago

jonasporto commented 8 years ago

I think that Array map method surprisingly doesn't apply as example of Functor

var a = [1, 2 , 3]; a.map(x => x) === a // false

the same for const b = [1, 2, 3]; b.map(x => x) === b // false

jethrolarson commented 8 years ago

Yeah we shouldn't use reference equality to define functor. We could use the setoid .equals for structural equality

On Fri, Jul 29, 2016, 3:32 PM Jonas Porto notifications@github.com wrote:

I think that Array map method surprisingly doesn't apply as example of Functor

var a = [1, 2 , 3]; a.map(x => x) === a // false

the same for const b = [1, 2, 3]; b.map(x => x) === b // false

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hemanth/functional-programming-jargon/issues/93, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB-4GP9gDeh_rVzBme-5AmRzQWhFOE6ks5qan-JgaJpZM4JYoV2 .

dead-claudia commented 8 years ago

I'll note that Fantasy Land defines equivalence as structural equality, not referential equality.