Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed shapeless from Scala 2, since it is fully replaced by Magnolia #603

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading