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 Fetch#runAll #194

Merged
merged 2 commits into from
May 20, 2019
Merged

Add Fetch#runAll #194

merged 2 commits into from
May 20, 2019

Conversation

purrgrammer
Copy link
Contributor

No description provided.

*/
def runAll[F[_]]: FetchRunnerAll[F] = new FetchRunnerAll[F]

private[fetch] class FetchRunnerAll[F[_]](private val dummy: Boolean = true) extends AnyVal {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of dummy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a dummy attribute to be able to define a class with the apply method diferent arities.

Copy link
Contributor

@diesalbla diesalbla May 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the problem of using just two functions?

def runAll[F[_]: Concurrent: Timer, A](fa: Fetch[F, A])
    : F[(Log, DataCache[F], A)] = 
  runAll(fa, InMemoryCache.empty[F])

def runAll[F[_]: Concurrent: Timer, A](fa: Fetch[F, A], cache: DataCache[F])
  : F[(Log, DataCache[F], A)] = /**/ 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use this technique to be able to partially apply the type parameters in Fetch.run* methods, so you can do Fetch.run[IO](f) and omit the second type parameter. It doesn't work with an overloaded method.

Copy link
Contributor

@diesalbla diesalbla May 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using a syntax extension on the Fetch[F, A] element?

implicit class FetchRunOps[F[_], A](val fa: Fetch[F, A]){
  def runAll()(implicit /****/) : F[(Log, DataCache[F], A)] = /***/

  def runAll(cache: DataCache[F])(implicit /***/) : F[(Log, DataCache[F], A)] = /***/
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still haven't added syntax for run* methods, it's actually a bit tricky. Opened #195 to address it.

@purrgrammer purrgrammer merged commit 88b14dd into master May 20, 2019
@purrgrammer purrgrammer deleted the run-all branch May 20, 2019 11:09
bijancn pushed a commit to bijancn/fetch that referenced this pull request Sep 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants