Skip to content

Commit

Permalink
Merge pull request #637 from scala-steward/update/scala3-library-3.3.4
Browse files Browse the repository at this point in the history
Update scala3-library, ... to 3.3.4
  • Loading branch information
satabin authored Oct 21, 2024
2 parents cadb26b + 04fcad9 commit 5e8cc19
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import scala.scalanative.build._

val scala212 = "2.12.20"
val scala213 = "2.13.15"
val scala3 = "3.3.3"
val scala3 = "3.3.4"
val fs2Version = "3.11.0"
val circeVersion = "0.14.8"
val circeExtrasVersion = "0.14.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ trait CellValue[T] {
def value: String
}

private class AnnotationCellValue[T](a: Annotation[CsvValue, T]) extends CellValue[T] {
def value: String = a().value
}

private class ConstantCellValue[T](val value: String) extends CellValue[T]

object CellValue {
inline given deriveSingleton[T](using m: Mirror.ProductOf[T] { type MirroredElemTypes = EmptyTuple }): CellValue[T] =
summonFrom {
case a: Annotation[CsvValue, T] => new CellValue[T] { def value: String = a().value }
case _ => new CellValue[T] { def value: String = constValue[m.MirroredLabel] }
case a: Annotation[CsvValue, T] => new AnnotationCellValue[T](a)
case _ => new ConstantCellValue[T](constValue[m.MirroredLabel])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ import scala.deriving.Mirror

trait DerivedCellDecoder[T] extends CellDecoder[T]

private class CoproductDerivedCellDecoder[T](decoders: List[DerivedCellDecoder[T]]) extends DerivedCellDecoder[T] {
def apply(in: String) =
decoders.foldRight(new DecoderError("Didn't match any value").asLeft)(_.apply(in).orElse(_))
}

object DerivedCellDecoder {
def expect[T](e: String, r: T): DerivedCellDecoder[T] = (in: String) =>
Either.cond(in == e, r, new DecoderError(s"Expected $e, got $in"))
Expand All @@ -38,10 +43,7 @@ object DerivedCellDecoder {
inline given deriveCoproduct[T](using m: Mirror.SumOf[T]): DerivedCellDecoder[T] = {
val decoders: List[DerivedCellDecoder[T]] =
summonAsArray[K0.LiftP[DerivedCellDecoder, m.MirroredElemTypes]].toList.asInstanceOf
new DerivedCellDecoder[T] {
def apply(in: String) =
decoders.foldRight(new DecoderError("Didn't match any value").asLeft)(_.apply(in).orElse(_))
}
new CoproductDerivedCellDecoder[T](decoders)
}

inline given deriveSingleton[T](using cv: CellValue[T], m: Mirror.ProductOf[T]): DerivedCellDecoder[T] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ object DerivedCellEncoder {
ce(t.productElement(0).asInstanceOf[Tuple.Head[m.MirroredElemTypes]])
}

inline given deriveCoproduct[T](using g: K0.CoproductInstances[DerivedCellEncoder, T]): DerivedCellEncoder[T] =
new DerivedCellEncoder[T] {
def apply(elem: T) = g.fold(elem)([t <: T] => (dce: DerivedCellEncoder[t], te: t) => dce(te))
}

inline given deriveSingleton[T](using cv: CellValue[T]): DerivedCellEncoder[T] =
new DerivedCellEncoder[T] {
def apply(t: T) = cv.value
}
inline given deriveCoproduct[T](using g: K0.CoproductInstances[DerivedCellEncoder, T]): DerivedCellEncoder[T] with {
def apply(elem: T) = g.fold(elem)([t <: T] => (dce: DerivedCellEncoder[t], te: t) => dce(te))
}

inline given deriveSingleton[T](using cv: CellValue[T]): DerivedCellEncoder[T] with {
def apply(t: T) = cv.value
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ package fs2
package data
package text

import scala.annotation.implicitNotFound
import org.typelevel.scalaccompat.annotation.*

import java.nio.charset.Charset
import scala.annotation.implicitNotFound

/** A typeclass witnessing that a stream of type `In` has chunks
* that can be iterated over to get characters.
Expand Down Expand Up @@ -74,6 +75,7 @@ trait CharLikeChunks[F[_], In] {

}

@nowarn3("cat=deprecation")
sealed trait AsCharBuffer[F[_], T] extends CharLikeChunks[F, T] {

def mark(ctx: Context): Unit
Expand Down

0 comments on commit 5e8cc19

Please sign in to comment.