-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb6784f
commit 13887e4
Showing
15 changed files
with
145 additions
and
77 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,6 @@ | ||
package tofu | ||
|
||
import tofu.internal.EffectComp | ||
|
||
object Start extends EffectComp[Start] | ||
|
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package tofu | ||
|
||
import cats.effect.Concurrent | ||
import scala.annotation.nowarn | ||
import cats.effect.IO | ||
import cats.effect.ContextShift | ||
|
||
@nowarn("msg=parameter") | ||
object StartSuite { | ||
def summonInstancesForConcurrent[F[_]: Concurrent] = { | ||
Fire[F] | ||
Start[F] | ||
Race[F] | ||
} | ||
|
||
def summonInstancesForIO(implicit cs: ContextShift[IO]) = { | ||
Fire[IO] | ||
Start[IO] | ||
Race[IO] | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package tofu | ||
|
||
import scala.util.Either | ||
import tofu.internal.{EffectComp, Effect2Comp} | ||
import tofu.internal.carriers.FibersCarrier | ||
|
||
trait Fire[F[_]] { | ||
def fireAndForget[A](fa: F[A]): F[Unit] | ||
} | ||
|
||
object Fire extends EffectComp[Fire] { | ||
final implicit def byCarrier[F[_], Fib[_]](implicit | ||
carrier: FibersCarrier.Aux[F, Fib] | ||
): Fibers[F, Fib] = carrier.content | ||
} | ||
|
||
trait Race[F[_]] extends Fire[F] { | ||
def race[A, B](fa: F[A], fb: F[B]): F[Either[A, B]] | ||
def never[A]: F[A] | ||
} | ||
|
||
object Race extends EffectComp[Race] { | ||
def never[F[_], A](implicit race: Race[F]): F[A] = race.never | ||
} | ||
|
||
trait Fibers[F[_], Fib[_]] extends Race[F] { | ||
def start[A](fa: F[A]): F[Fib[A]] | ||
def racePair[A, B](fa: F[A], fb: F[B]): F[Either[(A, Fib[B]), (Fib[A], B)]] | ||
} | ||
|
||
object Fibers extends Effect2Comp[Fibers] |
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
20 changes: 20 additions & 0 deletions
20
kernel/src/main/scala/tofu/internal/carriers/FibersCarrier.scala
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,20 @@ | ||
package tofu.internal.carriers | ||
import tofu.Fibers | ||
import tofu.internal.WBInterop | ||
|
||
abstract class FibersCarrier[F[_]] { | ||
type Fib[_] | ||
|
||
val content: Fibers[F, Fib] | ||
} | ||
|
||
object FibersCarrier { | ||
type Aux[F[_], Fb[_]] = FibersCarrier[F] { type Fib[a] = Fb[a] } | ||
def apply[F[_], Fb[_]](fin: Fibers[F, Fb]) = new FibersCarrier[F] { | ||
type Fib[a] = Fb[a] | ||
val content = fin | ||
} | ||
|
||
final implicit def startFromConcurrent[F[_], Exit[_]]: Aux[F, Exit] = | ||
macro WBInterop.delegate0[F, { val `tofu.interop.CE2Kernel.startFromConcurrent`: Unit }] | ||
} |
20 changes: 20 additions & 0 deletions
20
kernel/src/main/scala/tofu/internal/carriers/FinallyCarrier.scala
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,20 @@ | ||
package tofu.internal.carriers | ||
|
||
import tofu.Finally | ||
import tofu.internal.WBInterop | ||
|
||
abstract class FinallyCarrier[F[_], E] { | ||
type Exit[_] | ||
val content: Finally[F, Exit] | ||
} | ||
|
||
object FinallyCarrier { | ||
type Aux[F[_], E, Ex[_]] = FinallyCarrier[F, E] { type Exit[a] = Ex[a] } | ||
def apply[F[_], E, Ex[_]](fin: Finally[F, Ex]) = new FinallyCarrier[F, E] { | ||
type Exit[a] = Ex[a] | ||
val content = fin | ||
} | ||
|
||
final implicit def fromBracket[F[_], E, Exit[_]]: Aux[F, E, Exit] = | ||
macro WBInterop.delegate1[F, E, { val `tofu.interop.CE2Kernel.finallyFromBracket`: Unit }] | ||
} |
14 changes: 14 additions & 0 deletions
14
kernel/src/main/scala/tofu/internal/carriers/UnliftEffect.scala
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,14 @@ | ||
package tofu.internal.carriers | ||
|
||
import tofu.internal.Interop | ||
import tofu.lift.Unlift | ||
|
||
// This is purely workaround for scala 2.12 | ||
// Which denies to unfold a macro (and recieve a type error) | ||
// before checking an implicit for eligibility | ||
class UnliftEffect[F[_], G[_]](val value: Unlift[F, G]) extends AnyVal | ||
|
||
object UnliftEffect { | ||
final implicit def unliftIOEffect[F[_], G[_]]: UnliftEffect[F, G] = | ||
macro Interop.delegate[UnliftEffect[F, G], G, { val `tofu.interop.CE2Kernel.unliftEffect`: 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
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