This repository was archived by the owner on Jul 25, 2018. It is now read-only.

Description
According to the Fantasyland spec, v.ap(u.ap(a.map(f => g => x => f(g(x))))) must be equivalent to v.ap(u).ap(a) https://github.com/fantasyland/fantasy-land#apply .
I am using fantasy-io.js and trying to run the following tests:
const log = msg => x => {
console.log(msg, x);
return x;
};
const v = IO.of('v');
const u = IO.of(x => `u(${x})`);
const a = IO.of(x => `a(${x})`);
const testA = v.ap(u.ap(a.map(f => g => x => f(g(x)))))
.map(log('testA = '))
.unsafePerform();
const testB = v.ap(u).ap(a)
.map(log('testB = '))
.unsafePerform();
The result is:
TypeError: f is not a function on the line that says const testA = v.ap(u.ap(a.map(f => g => x => f(g(x)))))
When I swap a and this in the body of the function IO.prototype.ap, the tests succeed:
testA = a(u(v))
testB = a(u(v))