Apply composition law does not equate
See original GitHub issueIt could be that my implementation is not correct, but here’s the result of the test.
test.js
"use strict";
class Thing {
constructor(value) {
this.value = value;
}
ap(other) { return other.map(this.value); }
map(f) { return new Thing(f(this.value)); }
}
const y = new Thing(x => x);
const left = y.ap(y.ap(y.map(f => g => x => f(g(x)))));
const right = y.ap(y).ap(y)
console.log("left === right:", left === right);
console.log("left value:", left.value.toString());
console.log("right value:", right.value.toString());
Running test.js
$ node test
left === right: false
left value: g => x => f(g(x))
right value: x => x
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (11 by maintainers)
Top Results From Across the Web
Function composition where two functions are not equal
Yes, you can. To satisfy these conditions, g has to be the identity map on the range of f, but you can play...
Read more >Composition Law - an overview | ScienceDirect Topics
The composition law (s1,s2) ↦ (s1,s2) on the space of sections of π extends into a composition law on the space of sections...
Read more >Theorem for limits of composite functions - Khan Academy
This limit would be equal to the value of f(L), where L is the limit of g(x) at x=a, ... was left out);...
Read more >Function Composition is Associative - YouTube
Function Composition is Associative. Watch later. Share. Copy link. Info. Shopping. Tap to unmute. If playback doesn't begin shortly, ...
Read more >6.4: Composition of Functions - Mathematics LibreTexts
Since f(x)∈B, we can apply the function g to f(x), and we obtain g(f(x)), which is an element of C. Using this process,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Don’t contaminate your thoughts with this sort of comparison. 😉
I suggest comparing
ap
tomap
. They’re very similar:The type signatures are instructive:
ap
exists in Prelude as well.