frees-io / freestyle

A cohesive & pragmatic framework of FP centric Scala libraries

Home Page:http://frees.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FreeS.pure should return FreeS.Par

n3ziniuka5 opened this issue · 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.

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