New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement `Promise.of` #2

Closed
Raynos opened this Issue Apr 12, 2013 · 6 comments

Comments

Projects
None yet
2 participants
@Raynos

Raynos commented Apr 12, 2013

As per promises-aplus/constructor-spec#24 and https://github.com/pufuwozu/fantasy-land#constructorof-method

Should be pretty simple and then you'll have compliance

@briancavalier

This comment has been minimized.

Show comment
Hide comment
@briancavalier

briancavalier Apr 12, 2013

Owner

I'll do this in a branch for exploration. Can fantasy-land provide some code to help here? For example, a simple program that performs some abstract operations over the monad interface, where I can just plug an avow promise in and see it work?

Owner

briancavalier commented Apr 12, 2013

I'll do this in a branch for exploration. Can fantasy-land provide some code to help here? For example, a simple program that performs some abstract operations over the monad interface, where I can just plug an avow promise in and see it work?

@briancavalier

This comment has been minimized.

Show comment
Hide comment
@briancavalier
Owner

briancavalier commented Apr 12, 2013

Closed by e9e3725

@Raynos

This comment has been minimized.

Show comment
Hide comment
@Raynos

Raynos Apr 12, 2013

Does this work for a promise containing a promise ? or will that get flattened out?

Raynos commented Apr 12, 2013

Does this work for a promise containing a promise ? or will that get flattened out?

@briancavalier

This comment has been minimized.

Show comment
Hide comment
@briancavalier

briancavalier Apr 12, 2013

Owner

Yeah, of(x) uses x verbatim as the fulfillment value. For example:

avow.of(avow.of(123)).then(function(p) { console.log(typeof p.then === 'function'); });
Owner

briancavalier commented Apr 12, 2013

Yeah, of(x) uses x verbatim as the fulfillment value. For example:

avow.of(avow.of(123)).then(function(p) { console.log(typeof p.then === 'function'); });
@briancavalier

This comment has been minimized.

Show comment
Hide comment
@briancavalier

briancavalier Apr 12, 2013

Owner

However, I didn't change the flattening behavior of then().

Owner

briancavalier commented Apr 12, 2013

However, I didn't change the flattening behavior of then().

@Raynos

This comment has been minimized.

Show comment
Hide comment
@Raynos

Raynos Apr 12, 2013

That's ok. x.then(function (xValue) { return Promise.of(xValue) }) should correctly be "equivelant" to x. It's supposed to flatten one layer.

Of course x.then(function (xValue) { return Promise.of(Promise.of(xValue)) }) should be "equivelant" to Promise.of(x)

Raynos commented Apr 12, 2013

That's ok. x.then(function (xValue) { return Promise.of(xValue) }) should correctly be "equivelant" to x. It's supposed to flatten one layer.

Of course x.then(function (xValue) { return Promise.of(Promise.of(xValue)) }) should be "equivelant" to Promise.of(x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment