Skip to content
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

Add promise <-> monad bridge functions #35

Closed
char0n opened this issue Mar 2, 2017 · 24 comments
Closed

Add promise <-> monad bridge functions #35

char0n opened this issue Mar 2, 2017 · 24 comments
Assignees
Labels

Comments

@char0n
Copy link
Owner

char0n commented Mar 2, 2017

resolveP, allP, tapP, thenP, catchP, thenCatchP, rejectP, raceP, reduceP, isThenable, isPromise, tryP

@char0n char0n added the feature label Mar 2, 2017
@char0n char0n self-assigned this Mar 2, 2017
@char0n char0n mentioned this issue Mar 5, 2017
@char0n
Copy link
Owner Author

char0n commented Mar 29, 2017

resolveP = bind(Promise.resolve, Promise);

@rockymadden
Copy link
Collaborator

Something like https://github.com/kirillrogovoy/promised-pipe might also be useful.

@char0n
Copy link
Owner Author

char0n commented Jun 14, 2017

@rockymadden isn't pipeP what you're looking for ?

@rockymadden
Copy link
Collaborator

If all functions are return promises, yes. The promised-pipe brings the ability to intermix, at any point, sync and async functions.

@char0n
Copy link
Owner Author

char0n commented Jun 14, 2017

pipeP does the same. The only requirement is that first function in the pipe must be promise generator (returns promise).

const { add, subtract }  = require('ramda');

const resolveP = Promise.resolve.bind(Promise);
const asyncAdd = val => resolveP(val).then(add(1));

pipeP(
  resolveP,
  add(1),
  subtract(1),
  asyncAdd,
  add(2),
  subtract(1)
)(1);

@rockymadden
Copy link
Collaborator

rockymadden commented Jun 14, 2017

Nice, hmm yeah ignore me then. Thanks! BTW, I see some of what you are laying out here mentioned through out various Ramda issues on the topic of Promises (e.g. ramda/ramda#1869 (comment)). Lovely idea.

@char0n
Copy link
Owner Author

char0n commented Jun 14, 2017

NP

@rockymadden
Copy link
Collaborator

rockymadden commented Jun 14, 2017

Thoughts on your resolveP function (or R.bind(Promise.resolve, Promise)) being made into a standard function in adjunct (e.g. resolveP or ofP)? Seems to be generally usable to kick things off as a Promise.

EDIT: Ignore, I see it now as the first function in the list above.

@char0n
Copy link
Owner Author

char0n commented Jun 14, 2017

Yep, the plan is to implement it. Checkout out the first comment of this issue. It is the first function to be implemented for this issue ;]

@char0n
Copy link
Owner Author

char0n commented Jun 14, 2017

You can provide a pull request for it if you wish and become a contributor. ramda-adjunct ecosystem is ready to receive PR's and I always welcome any help. What do you think ?

@rockymadden
Copy link
Collaborator

Yep, love it. I've had a subset of this library internally for a while. Was reading through the Ramda wiki and saw ramda-adjunct, which was exactly what I myself was doing.

@char0n
Copy link
Owner Author

char0n commented Jun 14, 2017

Yep, I guess everybody is doing it. This library has a potential saving a lot of development time to a lot of people. Check this article to find out more.

Great, check out the CONTRIBUTING.md and you can start right away.

@char0n
Copy link
Owner Author

char0n commented Sep 17, 2017

Further inspirations: https://github.com/krainboltgreene/unction.js?files=1

char0n added a commit that referenced this issue Sep 17, 2017
char0n added a commit that referenced this issue Sep 17, 2017
@char0n char0n added this to the v2.1.0 milestone Nov 21, 2017
char0n added a commit that referenced this issue Nov 29, 2017
@char0n
Copy link
Owner Author

char0n commented Dec 1, 2017

char0n added a commit that referenced this issue Dec 1, 2017
char0n added a commit that referenced this issue Dec 1, 2017
char0n added a commit that referenced this issue Dec 1, 2017
char0n added a commit that referenced this issue Dec 1, 2017
char0n added a commit that referenced this issue Dec 1, 2017
char0n added a commit that referenced this issue Jan 7, 2018
@char0n char0n mentioned this issue Jan 7, 2018
char0n added a commit that referenced this issue Jan 9, 2018
@char0n char0n modified the milestones: v2.1.0, v2.5.0 Feb 6, 2018
@Undistraction Undistraction modified the milestones: v2.5.0, 2.6.0 Feb 16, 2018
@Undistraction
Copy link
Collaborator

@char0n You OK if I bump this to 2.7.0?

@char0n
Copy link
Owner Author

char0n commented Mar 8, 2018

Bump it up or remove the milestone entirely. Have no usecases for the rest of them right now.

@Undistraction Undistraction removed this from the 2.6.0 milestone Mar 8, 2018
@Undistraction
Copy link
Collaborator

@char0n When you get a chance maybe move remaining to separate issues.

@char0n
Copy link
Owner Author

char0n commented Mar 8, 2018

Yeah me or anybody else can do that.

Note for me and others: when doing it reference this issue in the child issues just for reference and then close this one.

char0n added a commit that referenced this issue May 13, 2018
char0n added a commit that referenced this issue May 13, 2018
char0n added a commit that referenced this issue May 13, 2018
@char0n char0n mentioned this issue May 13, 2018
char0n added a commit that referenced this issue May 13, 2018
char0n added a commit that referenced this issue May 13, 2018
@char0n char0n mentioned this issue Sep 6, 2018
@guillaumearm
Copy link
Collaborator

since #676, additional candidates are :

  • mapP
  • filterP
  • rejectP

IMO, we need to talk about parallel and series behavior, isn't ?

@char0n
Copy link
Owner Author

char0n commented Sep 10, 2018

Yes I think we should and I'm very interested in this discussion. But I'm still thinking about this in a context of already implemented reduceP. Does it make sense to have reduceP work in a parallel mode ?

Can you provide example of mapP being parallel and serial ?

@char0n char0n mentioned this issue Dec 24, 2019
@char0n
Copy link
Owner Author

char0n commented Dec 24, 2019

Created separate issue for raceP

@char0n
Copy link
Owner Author

char0n commented Dec 24, 2019

created separate issue for catchP

@char0n
Copy link
Owner Author

char0n commented Dec 24, 2019

created separate issue for thenCatchP

@char0n
Copy link
Owner Author

char0n commented Dec 24, 2019

Not going to implement tapP for now.

@char0n char0n closed this as completed Dec 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants