Last active
July 14, 2022 21:32
-
-
Save majk-p/5eb7317fe5b7c59844e40521729ba633 to your computer and use it in GitHub Desktop.
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
//> using scala "2" | |
//> using lib "org.typelevel::cats-core:2.8.0" | |
//> using lib "eu.timepit::refined:0.10.1" | |
//> using lib "io.circe::circe-core:0.14.2" | |
//> using lib "io.circe::circe-generic:0.14.2" | |
//> using lib "io.circe::circe-refined:0.14.2" | |
import cats.data.NonEmptyList | |
import eu.timepit.refined.auto._ | |
import eu.timepit.refined.api.Refined | |
import eu.timepit.refined.string._ | |
import eu.timepit.refined.types.string._ | |
import eu.timepit.refined.types.numeric._ | |
case class OrderLine(product: NonEmptyString, quantity: PosInt) | |
case class Order(orderId: String Refined Uuid, lines: NonEmptyList[OrderLine]) | |
val orderLines = NonEmptyList.of( | |
OrderLine("100", 10), | |
OrderLine("101", 5) | |
) | |
val order = Order( | |
"c93dd655-caca-4c99-aad8-3d91ad7a1b7e", | |
orderLines | |
) | |
println(order) | |
// OrderLine("", 10) // Doesn't compile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment