diff --git a/chimney-cats/src/test/scala-2.13+/io/scalaland/chimney/cats/CatsData213Spec.scala b/chimney-cats/src/test/scala-2.13+/io/scalaland/chimney/cats/CatsData213Spec.scala new file mode 100644 index 000000000..1b58c83ac --- /dev/null +++ b/chimney-cats/src/test/scala-2.13+/io/scalaland/chimney/cats/CatsData213Spec.scala @@ -0,0 +1,15 @@ +package io.scalaland.chimney.cats + +import cats.data.NonEmptyLazyList +import io.scalaland.chimney.ChimneySpec +import io.scalaland.chimney.dsl.* + +class CatsData213Spec extends ChimneySpec { + + test("DSL should handle transformation to and from cats.data.NonEmptyLazyList") { + List("test").transformIntoPartial[NonEmptyLazyList[String]].asOption ==> Some(NonEmptyLazyList("test")) + List.empty[String].transformIntoPartial[NonEmptyLazyList[String]].asOption ==> None + + NonEmptyLazyList("test").transformInto[List[String]] ==> List("test") + } +} diff --git a/docs/docs/cookbook.md b/docs/docs/cookbook.md index 38db27f94..eabc3b852 100644 --- a/docs/docs/cookbook.md +++ b/docs/docs/cookbook.md @@ -312,6 +312,16 @@ Cats integration module contains the following utilities: `UnorderedFoldable`, `Invariant`, `Semigriupal`, `NonEmptyAlternative`, `SemigroupK`, `MonoidK`) - `Parallel[partial.Result]` (implementing also`NonEmptyParallel`) - `Semigroup[partial.Result.Errors]` + - instances for `cats.data` types allowing Chimney to recognize them as collections: + - `cats.data.Chain` (transformation _from_ and _to_ always available) + - `cats.data.NonEmptyChain` (transformations: _from_ always available, _to_ only with `PartialTransformer`) + - `cats.data.NonEmptyLazyList` (transformation: _from_ always available, _to_ only with `PartialTransformer`, + the type is only defined on 2.13+) + - `cats.data.NonEmptyList` (transformation: _from_ always available, _to_ only with `PartialTransformer`) + - `cats.data.NonEmptyMap` (transformation: _from_ always available, _to_ only with `PartialTransformer`) + - `cats.data.NonEmptySeq` (transformation: _from_ always available, _to_ only with `PartialTransformer`) + - `cats.data.NonEmptySet` (transformation: _from_ always available, _to_ only with `PartialTransformer`) + - `cats.data.NonEmptyVector` (transformation: _from_ always available, _to_ only with `PartialTransformer`) !!! important @@ -1498,4 +1508,5 @@ The only 2 difference they make is that: - they allow usage of `everyMapKey` and `everyMapValue` in paths, just like with standard library's `Maps`. An example of such collections are `java.util` collections for which support is provided via `TotallyBuildIterable` -and `TotallyBuildMap` in [Java collections' integration](#java-collections-integration). +and `TotallyBuildMap` in [Java collections' integration](#java-collections-integration), or `cats.data` types +provided in [Cats integration](#cats-integration).