forked from zio/zio-json
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pull out Scalaz + Refined interop modules (zio#325)
* zioJsonInteropScalaz7x module * zioJsonInteropRefined module * Sort modules * Format build.sbt * Remove superfluous import
- Loading branch information
Showing
10 changed files
with
133 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
id: interop_refined | ||
title: "Refined Interop" | ||
--- | ||
|
||
## Installation | ||
|
||
```scala | ||
libraryDependencies ++= Seq( | ||
"@ORG@" % "zio-json-interop-refined" % "@RELEASE_VERSION@" | ||
) | ||
``` | ||
|
||
## Usage | ||
|
||
```scala mdoc | ||
import zio.json._ | ||
import zio.json.interop.refined._ | ||
|
||
import eu.timepit.refined.api.Refined | ||
import eu.timepit.refined.collection.NonEmpty | ||
|
||
case class Person(name: String Refined NonEmpty) | ||
|
||
object Person { | ||
implicit val decoder: JsonDecoder[Person] = DeriveJsonDecoder.gen | ||
} | ||
``` | ||
|
||
```scala mdoc | ||
"""{ "name": "" }""".fromJson[Person] | ||
``` | ||
|
||
```scala mdoc | ||
"""{ "name": "Aurora" }""".fromJson[Person] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
id: interop_scalaz_7x | ||
title: "Scalaz 7.x Interop" | ||
--- | ||
|
||
## Installation | ||
|
||
```scala | ||
libraryDependencies ++= Seq( | ||
"@ORG@" % "zio-json-interop-scalaz" % "@RELEASE_VERSION@" | ||
) | ||
``` | ||
|
||
## Usage | ||
|
||
```scala mdoc | ||
import zio.json._ | ||
import zio.json.interop.scalaz7x._ | ||
|
||
import scalaz._ | ||
|
||
IList(1, 2, 3).toJson | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../main/scala/zio/json/compat/refined.scala → ...la/zio/json/interop/refined/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...t/scala/zio/json/compat/RefinedSpec.scala → ...io/json/interop/refined/RefinedSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions
9
...c/main/scala/zio/json/compat/scalaz.scala → ...a/zio/json/interop/scalaz7x/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
package zio.json.compat | ||
package zio.json.interop | ||
|
||
import _root_.scalaz._ | ||
import scalaz._ | ||
|
||
import zio.json._ | ||
|
||
object scalaz { | ||
|
||
package object scalaz7x { | ||
implicit def ilistEncoder[A: JsonEncoder]: JsonEncoder[IList[A]] = | ||
JsonEncoder.list[A].contramap(_.toList) | ||
|
||
implicit def ilistJsonDecoder[A: JsonDecoder]: JsonDecoder[IList[A]] = | ||
JsonDecoder.list[A].map(IList.fromList(_)) | ||
|
||
} |
10 changes: 5 additions & 5 deletions
10
...st/scala/zio/json/compat/ScalazSpec.scala → .../zio/json/interop/scalaz/ScalazSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters