freestyle icon indicating copy to clipboard operation
freestyle copied to clipboard

FreeS.pure should return FreeS.Par

Open n3ziniuka5 opened this issue 7 years ago • 1 comments

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 avatar Apr 22 '18 09:04 n3ziniuka5

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

n3ziniuka5 avatar Apr 22 '18 16:04 n3ziniuka5