diff --git a/build.sbt b/build.sbt index 69557c3..ab1442d 100644 --- a/build.sbt +++ b/build.sbt @@ -26,7 +26,7 @@ addCommandAlias("fixCheck", "scalafmtCheckAll") addCommandAlias("fix", "scalafmtAll") val commonSettings = Seq( - version := "0.2.1", + version := "0.2.2", scalaVersion := "3.3.0", scalacOptions ++= Seq( "-explain", diff --git a/modules/core/src/main/scala/muffin/internal/router/RouterDSL.scala b/modules/core/src/main/scala/muffin/internal/router/RouterDSL.scala index 522e124..a567f21 100644 --- a/modules/core/src/main/scala/muffin/internal/router/RouterDSL.scala +++ b/modules/core/src/main/scala/muffin/internal/router/RouterDSL.scala @@ -16,7 +16,7 @@ case class Handle[F[ object Handle { - extension [F[ + implicit class RouterOps[F[ _ ], H, N <: Singleton, CommandName <: Tuple, ActionName <: Tuple, ActionIn <: Tuple, DialogName <: Tuple, DialogIn <: Tuple]( h: Handle[F, H, N, CommandName, ActionName, ActionIn, DialogName, DialogIn] diff --git a/modules/integration/circe-json-interop/src/main/scala/muffin/interop/json/circe/codec.scala b/modules/integration/circe-json-interop/src/main/scala/muffin/interop/json/circe/codec.scala index 94efbb9..6ea6a66 100644 --- a/modules/integration/circe-json-interop/src/main/scala/muffin/interop/json/circe/codec.scala +++ b/modules/integration/circe-json-interop/src/main/scala/muffin/interop/json/circe/codec.scala @@ -14,7 +14,16 @@ import muffin.codec.* import muffin.error.MuffinError import muffin.http.Body -object codec extends CodecSupport[Encoder, Decoder] { + +object codec extends codecA + +trait codecA extends CodecLow { + given NothingTo: io.circe.Encoder[Nothing] = UnitTo.asInstanceOf[Encoder[Nothing]] + + given NothingFrom: io.circe.Decoder[Nothing] = UnitFrom.asInstanceOf[Decoder[Nothing]] +} + +trait CodecLow extends CodecSupport[Encoder, Decoder] { given EncoderTo: FunctionK[Encoder, Encode] = new FunctionK[Encoder, Encode] { @@ -68,10 +77,6 @@ object codec extends CodecSupport[Encoder, Decoder] { given LongFrom: io.circe.Decoder[Long] = Decoder.decodeLong - given NothingTo: io.circe.Encoder[Nothing] = UnitTo.asInstanceOf[Encoder[Nothing]] - - given NothingFrom: io.circe.Decoder[Nothing] = UnitFrom.asInstanceOf[Decoder[Nothing]] - given AnyTo: io.circe.Encoder[Any] = UnitTo.asInstanceOf[Encoder[Any]] given AnyFrom: io.circe.Decoder[Any] = UnitFrom.asInstanceOf[Decoder[Any]] diff --git a/modules/integration/zio-json-interop/src/main/scala/muffin/interop/json/zio/codec.scala b/modules/integration/zio-json-interop/src/main/scala/muffin/interop/json/zio/codec.scala index feb803f..1412f65 100644 --- a/modules/integration/zio-json-interop/src/main/scala/muffin/interop/json/zio/codec.scala +++ b/modules/integration/zio-json-interop/src/main/scala/muffin/interop/json/zio/codec.scala @@ -11,7 +11,13 @@ import muffin.codec.* import muffin.error.MuffinError import muffin.http.Body -object codec extends CodecSupport[JsonEncoder, JsonDecoder] { +object codec extends CodecA { + given NothingTo: JsonEncoder[Nothing] = UnitTo.asInstanceOf[JsonEncoder[Nothing]] + + given NothingFrom: JsonDecoder[Nothing] = UnitFrom.asInstanceOf[JsonDecoder[Nothing]] +} + +trait CodecA extends CodecSupport[JsonEncoder, JsonDecoder] { given EncodeTo[A: JsonEncoder]: Encode[A] = _.toJson @@ -53,10 +59,6 @@ object codec extends CodecSupport[JsonEncoder, JsonDecoder] { given LongFrom: JsonDecoder[Long] = JsonDecoder.long - given NothingTo: JsonEncoder[Nothing] = UnitTo.asInstanceOf[JsonEncoder[Nothing]] - - given NothingFrom: JsonDecoder[Nothing] = UnitFrom.asInstanceOf[JsonDecoder[Nothing]] - given AnyTo: JsonEncoder[Any] = UnitTo.asInstanceOf[JsonEncoder[Any]] given AnyFrom: JsonDecoder[Any] = UnitFrom.asInstanceOf[JsonDecoder[Any]]