DEV Community

Discussion on: Functional design: combinators

Collapse
 
naorzr profile image
naorzr

Great article,

Small correction, I believe "contramap" is logically wrong.
Just because we have a function from B->A doesn't necessarily means that applying these functions and then using equal is the same as applying equal to the instances of B.
it lacks assumptions for this to be true.
for example:
lets say B is simply numbers, and A are simply strings,
the function that converts these operate by the following logic, all positive numbers transformed to the latter 'p', and all the negatives to the latter 'n',
so,
f(2) === f(3)
but 2!==3.

Collapse
 
gcanti profile image
Giulio Canti

but 2!==3

Actually they are equal, under the equivalence relation induced by the function f which is defined as:

x = y if and only if f(x) = f(y)

see "Equivalence kernel" here en.wikipedia.org/wiki/Equivalence_...