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

FreeS.pure should return FreeS.Par #549

Open
n3ziniuka5 opened this issue Apr 22, 2018 · 1 comment
Open

FreeS.pure should return FreeS.Par #549

n3ziniuka5 opened this issue Apr 22, 2018 · 1 comment

Comments

@n3ziniuka5
Copy link

Sometimes you want to run operation in parallel that depends on a previous result that may be an option, for example:

for {
  someOption <- op1
  val op2 = someOption.map(op2).getOrElse(FreeS.pure(()))
  val op3 = someOption.map(op3).getOrElse(FreeS.pure(()))
  _ <- (op2, op3).tupled
} yield ()

Currently you cannot do this as FreeS.pure returns FreeS[F, A] and not FreeS.Par[F, A]. For now I just wrote an additional utilities algebra with one of the operations being pure and that gives me the type that allows for parallelism.

@n3ziniuka5
Copy link
Author

Just tested and this change would break getOrElse when the option type is FreeS, so maybe there should be another method FreeS.purePar.

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

No branches or pull requests

1 participant