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

First stab at flatMapLoop for Task and Coeval #1010

Merged
merged 3 commits into from Oct 22, 2019

Conversation

@mudsam
Copy link
Contributor

mudsam commented Sep 6, 2019

@alexandru alexandru changed the title First stab at flatMapLoop for Task and Coeval, Work in Progress. [WIP] First stab at flatMapLoop for Task and Coeval Sep 8, 2019
@alexandru

This comment has been minimized.

Copy link
Member

alexandru commented Sep 8, 2019

Cool. Needs documentation I think.

@mudsam

This comment has been minimized.

Copy link
Contributor Author

mudsam commented Sep 14, 2019

Apologies for the delay, how about this as documentation?

  /** Enables flatMap loops over Tasks
    * 
    * Sample:
    * 
    * {{{
    *   val random = Task(Random.nextInt())
    *   val loop = random.flatMapLoop(Vector.empty[Int]) { (a, list, continue) =>
    *     val newList = list :+ a
    *     if (newList.length < 5)
    *       continue(newList)
    *     else
    *       Task.now(newList)
    *   }
    * }}}
    * 
    * @param seed initializes the output
    * @param f is a function that takes three inputs and returns a [[Task]]:
    *        1. the next value
    *        2. the accumulated result of the loop
    *        3. the continuation function of the loop.
    * @return a new [[Task]] that contains the result of the loop.
    */
@alexandru

This comment has been minimized.

Copy link
Member

alexandru commented Sep 16, 2019

@mudsam that looks good, not sure if that list will be formatted properly. You can check by generating the documentation with unidoc.

Also instead of this:

Enables flatMap loops over Tasks

You might say something like this:

Describes flatMap-driven loops, as an alternative to recursive functions.

mudsam added 2 commits Sep 18, 2019
@alexandru alexandru changed the title [WIP] First stab at flatMapLoop for Task and Coeval First stab at flatMapLoop for Task and Coeval Oct 22, 2019
@alexandru alexandru merged commit c858475 into monix:master Oct 22, 2019
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.