ducktape 0.2.3
ducktape 0.2.3
This release brings the ability to transform tuples in all kind of ways (tuple-to-tuple, product-to-tuple, tuple-to-product), so stuff like this is now possible:
import io.github.arainko.ducktape.*
case class Source(field1: Int, field2: List[Int], field3: Int, field4: Int)
Source(1, List(2, 2, 2), 3, 4).to[(Int, Vector[Int], Option[Int])]
// res18: Tuple3[Int, Vector[Int], Option[Int]] = (
// 1,
// Vector(2, 2, 2),
// Some(value = 3)
// )
(1, List(2, 2, 2), 3, 4).to[Source]
// res19: Source = Source(
// field1 = 1,
// field2 = List(2, 2, 2),
// field3 = 3,
// field4 = 4
// )
The newly added ability for F-unwrapping
(i.e. lifting the wrapper type into the 'outside' of a fallible transformation) in conjuction with tuple transformation enables some fantastic use cases for match types, like the ability to 'traverse' a tuple:
import io.github.arainko.ducktape.*
val source =
(
Right(1),
Right("str"),
Right(List(3, 3, 3)),
Right(4)
)
Mode.Accumulating.either[String, List].locally {
source.fallibleTo[Tuple.InverseMap[source.type, Mode.current.Self]]
}
// res0: Either[List[String], *:[Int, *:[String, *:[List[Int], *:[Int, EmptyTuple]]]]] = Right(
// value = (1, "str", List(3, 3, 3), 4)
// )
...which is really just the tip of the iceberg - stay tuned for a more in-depth look on how this mechanism can be leveraged in other use cases.
Head on over to the docs on configuring tuples to see how the configuration DSL works with tuples.
What's Changed
- Update README.md by @arainko in #172
- Update nscplugin, sbt-scala-native to 0.5.3 by @scala-steward in #171
- Refactor
Debug
by @arainko in #174 - Update sbt-mdoc to 2.5.3 by @scala-steward in #175
- Update auxlib, clib, javalib, nativelib, ... to 0.5.4 by @scala-steward in #176
- [Issue 154] Tuple transformations by @arainko in #177
- Update sbt to 1.10.1 by @scala-steward in #180
- Update sbt-mdoc to 2.5.4 by @scala-steward in #181
- [Issue 178] F-unwrapping by @arainko in #182
- F-unwrapping cleanup by @arainko in #183
Full Changelog: v0.2.2...v0.2.3