Skip to content

Commit

Permalink
Merge pull request #35 from jatcwang/validated
Browse files Browse the repository at this point in the history
feat: Add instances for cats.data.Chain and cats.data.Validated
  • Loading branch information
jatcwang authored Mar 16, 2024
2 parents 14b2840 + c2464f5 commit 47a5ead
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/docs/docs/LibraryIntegrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ object MyTest extends SimpleIOSuite {
Differ instances for cats data structures like `NonEmptyList` and `Chain` can be found in

```
"com.github.jatcwang" %% "difflicious-scalatest" % "{{ site.version }}" % Test
"com.github.jatcwang" %% "difflicious-cats" % "{{ site.version }}" % Test
```

```scala mdoc:nest
Expand Down
16 changes: 16 additions & 0 deletions modules/cats/src/main/scala/difflicious/cats/CatsInstances.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,22 @@ trait CatsInstances {
)
}

implicit def chainDiffer[A](
implicit aDiffer: Differ[A],
typeName: TypeName[Chain[A]],
): SeqDiffer[Chain, A] = {
SeqDiffer.create(
itemDiffer = aDiffer,
typeName = typeName.copy(
long = "cats.data.Chain",
short = "Chain",
),
asSeq = chainAsSeq,
)
}

implicit def validatedDiffer[E: Differ, A: Differ]: Differ[Validated[E, A]] = Differ.derived

}

object CatsInstances extends CatsInstances

0 comments on commit 47a5ead

Please sign in to comment.