-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLose #261 - Add FxCtor as an alternative to EffectConstructor
- Loading branch information
Showing
77 changed files
with
1,822 additions
and
479 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,42 @@ | ||
package effectie.cats | ||
|
||
import cats.Id | ||
import cats.effect.IO | ||
import cats.Id | ||
import effectie.{CommonFx, OldEffectConstructor} | ||
|
||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
trait Fx[F[_]] extends CommonFx[F] with OldEffectConstructor[F] | ||
trait Fx[F[_]] extends EffectConstructor[F] with FxCtor[F] with CommonFx[F] with OldEffectConstructor[F] | ||
|
||
object Fx { | ||
def apply[F[_]: Fx]: Fx[F] = implicitly[Fx[F]] | ||
|
||
implicit final val ioFx: Fx[IO] = EffectConstructor.ioEffectConstructor | ||
implicit object IoFx extends Fx[IO] { | ||
|
||
@inline override def effectOf[A](a: => A): IO[A] = IO(a) | ||
|
||
@inline override def pureOf[A](a: A): IO[A] = IO.pure(a) | ||
|
||
@inline override val unitOf: IO[Unit] = IO.unit | ||
} | ||
|
||
@SuppressWarnings(Array("org.wartremover.warts.ImplicitParameter")) | ||
implicit def futureFx(implicit EC: ExecutionContext): Fx[Future] = | ||
EffectConstructor.futureEffectConstructor(EC) | ||
implicit def futureFx(implicit EC: ExecutionContext): Fx[Future] = new FutureFx | ||
|
||
final class FutureFx(implicit override val EC0: ExecutionContext) | ||
extends Fx[Future] | ||
with EffectConstructor[Future] | ||
with FxCtor[Future] | ||
with CommonFx.CommonFutureFx | ||
with OldEffectConstructor.OldFutureEffectConstructor | ||
|
||
implicit object IdFx extends Fx[Id] { | ||
|
||
@inline override def effectOf[A](a: => A): Id[A] = a | ||
|
||
@inline override def pureOf[A](a: A): Id[A] = a | ||
|
||
implicit final val idFx: Fx[Id] = EffectConstructor.idEffectConstructor | ||
@inline override val unitOf: Id[Unit] = () | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package effectie.cats | ||
|
||
import cats.Id | ||
import cats.effect.IO | ||
import effectie.{CommonFx, OldEffectConstructor} | ||
|
||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
trait FxCtor[F[_]] extends CommonFx[F] with OldEffectConstructor[F] | ||
|
||
object FxCtor { | ||
def apply[F[_]: FxCtor]: FxCtor[F] = implicitly[FxCtor[F]] | ||
|
||
implicit final val ioFxCtor: FxCtor[IO] = Fx.IoFx | ||
|
||
@SuppressWarnings(Array("org.wartremover.warts.ImplicitParameter")) | ||
implicit def futureFxCtor(implicit EC: ExecutionContext): FxCtor[Future] = | ||
Fx.futureFx | ||
|
||
implicit final val idFxCtor: FxCtor[Id] = Fx.IdFx | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.