Automatic and customizable compile time transformations between similar case classes and sealed traits/enums, essentially a thing that glues your code. Scala 3 only. Or is it duct 🤔
test("Field.fallibleComputedDeep works with F-wrapped values") {
case class SourceToplevel1(level1: Vector[SourceLevel1])
case class SourceLevel1(level2: Vector[SourceLevel2])
case class SourceLevel2(level3: Vector[SourceLevel3])
case class SourceLevel3(int: Either[List[String], Int])
case class DestToplevel1(level1: List[DestLevel1])
case class DestLevel1(level2: List[DestLevel2])
case class DestLevel2(level3: List[DestLevel3])
case class DestLevel3(int: Either[List[String], Int])
val source = SourceToplevel1(Vector(SourceLevel1(Vector(SourceLevel2(Vector(SourceLevel3(Right(1))))))))
val expected = DestToplevel1(List(DestLevel1(List(DestLevel2(List(DestLevel3(Right(11))))))))
assertTransformsFallibleConfigured(source, F.pure(expected))(
Field.fallibleComputedDeep(
_.level1.element.level2.element.level3.element.int.element,
(int: Int) => Right(int + 10)
)
)
}
changing line 57 in PathSelector.scala
case Apply(
Apply(
TypeApply(Select(Ident(_), "element"), elemTpe :: _ :: Nil),
_
),
tree :: Nil
) =>
Logger.debug(s"Matched 'element' of F[Elem] selection", elemTpe.tpe.asType)
recurse(acc.prepended(Path.Segment.Element(elemTpe.tpe.asType)), tree)
to _ fixes the parsing issue, but the path is still rejected - I'd expect it to work (? to be determined tbh)
changing line 57 in PathSelector.scala
to
_
fixes the parsing issue, but the path is still rejected - I'd expect it to work (? to be determined tbh)