Skip to content

Instantly share code, notes, and snippets.

@djspiewak
Created March 3, 2025 19:19
Show Gist options
  • Save djspiewak/c0e9ca2cd1c30870ee390ffb78b5040b to your computer and use it in GitHub Desktop.
Save djspiewak/c0e9ca2cd1c30870ee390ffb78b5040b to your computer and use it in GitHub Desktop.
diff --git a/core/src/main/scala-3 b/core/src/main/scala-3
deleted file mode 120000
index 609602e..0000000
--- a/core/src/main/scala-3
+++ /dev/null
@@ -1 +0,0 @@
-scala-2.13
\ No newline at end of file
diff --git a/core/src/main/scala/cats/mtl/Handle.scala b/core/src/main/scala/cats/mtl/Handle.scala
index e8bb1f7..e304b58 100644
--- a/core/src/main/scala/cats/mtl/Handle.scala
+++ b/core/src/main/scala/cats/mtl/Handle.scala
@@ -218,14 +218,15 @@ private[mtl] trait HandleInstances extends HandleLowPriorityInstances {
}
}
-object Handle extends HandleInstances {
+object Handle extends HandleInstances with HandleVariant {
def apply[F[_], E](implicit ev: Handle[F, E]): Handle[F, E] = ev
- def allow[F[_], E]: AdHocSyntax[F, E] =
- new AdHocSyntax[F, E]
- final class AdHocSyntax[F[_], E] {
+ def allowF[F[_], E]: AdHocSyntaxTired[F, E] =
+ new AdHocSyntaxTired[F, E]
+
+ final class AdHocSyntaxTired[F[_], E] {
def apply[A](body: Handle[F, E] => F[A])(implicit F: ApplicativeThrow[F]): Inner[A] =
new Inner(body)
@@ -252,7 +253,7 @@ object Handle extends HandleInstances {
}
}
- private final case class Submarine[E](e: E, marker: AnyRef)
+ private[mtl] final case class Submarine[E](e: E, marker: AnyRef)
extends RuntimeException
with NoStackTrace
}
diff --git a/tests/shared/src/test/scala/cats/mtl/tests/HandleTests.scala b/tests/shared/src/test/scala/cats/mtl/tests/HandleTests.scala
index f8a127b..1454914 100644
--- a/tests/shared/src/test/scala/cats/mtl/tests/HandleTests.scala
+++ b/tests/shared/src/test/scala/cats/mtl/tests/HandleTests.scala
@@ -57,7 +57,7 @@ class HandleTests extends BaseSuite {
}
val test =
- Handle.allow[F, Error](implicit h => Error.Second.raise.as("nope")) rescue {
+ Handle.allowF[F, Error](implicit h => Error.Second.raise.as("nope")) rescue {
case Error.First => "0".pure[F]
case Error.Second => "1".pure[F]
case Error.Third => "2".pure[F]
@@ -77,8 +77,8 @@ class HandleTests extends BaseSuite {
sealed trait Error2 extends Product with Serializable
- val test = Handle.allow[F, Error1] { implicit h1 =>
- Handle.allow[F, Error2] { implicit h2 =>
+ val test = Handle.allowF[F, Error1] { implicit h1 =>
+ Handle.allowF[F, Error2] { implicit h2 =>
val _ =
h2 // it's helpful to test the raise syntax infers even when multiple handles are present
Error1.Third.raise.as("nope")
@@ -109,11 +109,11 @@ class HandleTests extends BaseSuite {
implicit val eqThrowable: Eq[Throwable] =
Eq.fromUniversalEquals[Throwable]
- val test = Handle.allow[F, Error] { implicit h =>
+ val test = Handle.allowF[F, Error] { implicit h =>
EitherT liftF {
Eval later {
checkAll(
- "Handle.allow[F, Error]",
+ "Handle.allowF[F, Error]",
cats.mtl.laws.discipline.HandleTests[F, Error].handle[Int])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment