Open nadameu opened 7 years ago
This lib is outdated, it is supporting old version of fantasy-land
@nadameu What are you using for the IO monad now? End up writing something?
It would be better to update this lib then write new one PRs are welcome!
@safareli What are you using to model IO?
@mwalkerwells I usually write my FL implementations from scratch, since I write mostly Greasemonkey scripts, which makes working with libraries (imports/exports) difficult.
Also, most implementations have a lot of methods I usually don't need, and I need my code to be lightweight.
I like this style:
const IO = performUnsafeIO => ({
performUnsafeIO,
ap: a => IO(() => a.performUnsafeIO()(performUnsafeIO())),
chain: f => IO(() => f(performUnsafeIO()).performUnsafeIO()),
map: f => IO(() => f(performUnsafeIO()))
});
IO.of = x => IO(() => x);
Ah, gotcha. I was also actually thinking of forking to be FL compliant. Any reason you haven't submitted a PR upstream?
Pull request #3 submitted
Love it man 👍🏻👍🏻
According to the Fantasyland spec,
v.ap(u.ap(a.map(f => g => x => f(g(x)))))
must be equivalent tov.ap(u).ap(a)
https://github.com/fantasyland/fantasy-land#apply .I am using fantasy-io.js and trying to run the following tests:
The result is:
TypeError: f is not a function
on the line that saysconst testA = v.ap(u.ap(a.map(f => g => x => f(g(x)))))
When I swap
a
andthis
in the body of the functionIO.prototype.ap
, the tests succeed: