Skip to content

Commit

Permalink
Removed shapeless from scala 2, since it is fully replaced by Magnolia
Browse files Browse the repository at this point in the history
  • Loading branch information
soujiro32167 committed Jul 15, 2024
1 parent bfdddbd commit c0c51af
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 274 deletions.
1 change: 0 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ lazy val generic = project
if (scalaVersion.value.startsWith("2"))
Seq(
"com.propensive" %% "magnolia" % magnolia2Version,
"com.chuusai" %% "shapeless" % shapelessVersion,
"org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided
)
else
Expand Down
42 changes: 5 additions & 37 deletions modules/generic/src/main/scala-2/vulcan/generic/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,16 @@

package vulcan

import scala.language.experimental.macros
import scala.reflect.runtime.universe.WeakTypeTag
import cats.data.Chain
import cats.free.FreeApplicative
import cats.implicits._
import magnolia._
import shapeless.{:+:, CNil, Coproduct, Inl, Inr, Lazy}
import shapeless.ops.coproduct.{Inject, Selector}
import vulcan.internal.tags._
import cats.data.Chain
import cats.free.FreeApplicative

package object generic {
implicit final val cnilCodec: Codec.Aux[Nothing, CNil] =
Codec.UnionCodec(Chain.empty).asInstanceOf[Codec.Aux[Nothing, CNil]].withTypeName("Coproduct")

implicit final def coproductCodec[H, T <: Coproduct](
implicit headCodec: Codec[H],
tailCodec: Lazy[Codec[T]]
): Codec[H :+: T] =
tailCodec.value match {
case Codec.WithTypeName(Codec.Validated(u: Codec.UnionCodec[T], _), typeName) =>
val tailAlts: Chain[Codec.Alt[H :+: T]] =
u.alts.map(_.imap[H :+: T](_.eliminate(_ => None, Some(_)), Inr(_)))
Codec
.UnionCodec(
tailAlts
.prepend(
Codec.Alt(headCodec, Prism.instance[H :+: T, H](_.select)(Inl(_)))
)
)
.withTypeName(typeName)
case Codec.Fail(error) => Codec.Fail(error)
case other =>
throw new IllegalArgumentException(
s"cannot derive coproduct codec from non-union ${other.getClass()}"
)
}
import scala.language.experimental.macros
import scala.reflect.runtime.universe.WeakTypeTag

implicit final def coproductPrism[C <: Coproduct, A](
implicit inject: Inject[C, A],
selector: Selector[C, A]
): Prism[C, A] =
Prism.instance(selector(_))(inject(_))
package object generic {

implicit final class MagnoliaCodec private[generic] (
private val codec: Codec.type
Expand Down
12 changes: 6 additions & 6 deletions modules/generic/src/main/scala-3/vulcan/generic/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
package vulcan


import org.apache.avro.generic._
import org.apache.avro.generic.*
import org.apache.avro.Schema
import shapeless3.deriving._
import scala.compiletime._
import scala.compiletime.*
import scala.reflect.ClassTag
import scala.deriving.Mirror
import cats.data.Chain
import cats.implicits._
import cats.implicits.*
import cats.free.FreeApplicative
import magnolia1._
import org.apache.avro.generic._
import magnolia1.*
import org.apache.avro.generic.*
import org.apache.avro.Schema
import vulcan.internal.converters.collection._
import vulcan.internal.converters.collection.*

package object generic {

Expand Down

This file was deleted.

This file was deleted.

0 comments on commit c0c51af

Please sign in to comment.