Created
June 27, 2024 11:15
-
-
Save ticofab/ef80013fb4d6a34762195da6fbbe2f9a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 3.4.2 | |
//> using dep com.chuusai:shapeless_2.13:2.3.12 | |
// { | |
// "name": "ExampleObject", | |
// "namespace": "example.namespace" | |
// "type": "record", | |
// "fields": [ | |
// { | |
// "name": "location", | |
// "type": "string" | |
// } | |
// ] | |
// } | |
// | |
// { | |
// "type": "record", | |
// "name": "ExampleRecord", | |
// "fields": [ | |
// { | |
// "name": "exampleField", | |
// "type": [ | |
// "string", | |
// "int", | |
// "example.namespace.ExampleObject" | |
// ] | |
// } | |
// ] | |
// } | |
import shapeless.{:+:, CNil, Coproduct} | |
final case class ExampleObject(location: String) | |
final case class ExampleRecord( | |
exampleField: Int :+: String :+: ExampleObject :+: CNil) | |
object Main extends App: | |
val myObject = ExampleObject("london") | |
val myRecord = ExampleRecord( | |
Coproduct[ExampleObject](myObject) | |
) | |
println(myRecord) | |
// Compiling project (Scala 3.4.2, JVM (22)) | |
// [error] ./scala3shapeless2.scala:42:39 | |
// [error] No given instance of type shapeless.ops.coproduct.Inject[ExampleObject, ExampleObject] was found for parameter inj of method apply in class MkCoproduct | |
// [error] | |
// [error] One of the following imports might make progress towards fixing the problem: | |
// [error] | |
// [error] import shapeless.~?>.idKeyWitness | |
// [error] import shapeless.~?>.idValueWitness | |
// [error] import shapeless.~?>.witness | |
// [error] | |
// [error] Coproduct[ExampleObject](myObject) | |
// [error] ^ | |
// Error compiling project (Scala 3.4.2, JVM (22)) | |
// Compilation failed | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment