typelevel / typelevel/cats

Instances for Future

Open
#2,334 18 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Source Breaking Triage needed
Dominant language
Scala
Stars
5.5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
5

Description

Future is largely known to not be referentially transparent. As it starts execution immediately and caches the result.

While it may have been largely necessary for these instances to be in cats before cats-effect, with that solution coming in maturity it may be time for Future instances to be pushed to alleycats.

Imports

import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
import cats.implicits._ 

Example 1 - Prints Once on the first line

val future1 : Future[Unit] = Future(println("I printed"))
val futureResult1 : Future[Unit] = (future1, future1).mapN(_ => ())

Example 2 - Prints twice on the second line

def future2: Future[Unit] = Future(println("I printed"))
val futureResult2 : Future[Unit] = (future2, future2).mapN(_ => ())

As you can see we have lost equational reasoning.

What are your thoughts on the future of Future?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the issue's scala.concurrent.Future examples and imports, then review how the Future instances relate to cats-effect and the proposed alleycats placement. Done would require a maintainer decision on whether the instances remain in cats or move, with an agreed scope for any follow-up changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
api
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.