最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

scala - upickle ReadWriter for case class does not compile - Stack Overflow

programmeradmin4浏览0评论

The Scala 3.6.3 code

case class LichessDuels(id: String, p: Array[LichessDuelInterna]) derives ReadWriter
  
case class LichessDuelInterna(n: String, r: Int, k: Int) derives ReadWriter

does not compile. Error message:

  case class LichessDuels(id: String, p: Array[LichessDuelInterna]) derives ReadWriter
[error]     |                                                                            ^
[error]     |No best given instance of type WritersVersionSpecific_this.Writer[
[error]     |  Array[
[error]     |    de.qno.tournamentadmin.lichess.LichessInternalDataTypes.LichessDuelInterna]
[error]     |] was found.
[error]     |I found:
[error]     |
[error]     |    upickle.default.ReadWriter.join[
[error]     |
[error]     |        Array[
[error]     |          de.qno.tournamentadmin.lichess.LichessInternalDataTypes.LichessDuelInterna
[error]     |          ]
[error]     |
[error]     |    ](
[error]     |      upickle.default.ReadWriter.join[
[error]     |
[error]     |          Array[
[error]     |            de.qno.tournamentadmin.lichess.LichessInternalDataTypes.
[error]     |              LichessDuelInterna
[error]     |          ]
[error]     |
[error]     |      ](
[error]     |        upickle.default.ArrayReader[
[error]     |          de.qno.tournamentadmin.lichess.LichessInternalDataTypes.LichessDuelInterna
[error]     |          ](
[error]     |          upickle.default.ReadWriter.join[
[error]     |
[error]     |              de.qno.tournamentadmin.lichess.LichessInternalDataTypes.
[error]     |                LichessDuelInterna
[error]     |
[error]     |          ](
[error]     |            de.qno.tournamentadmin.lichess.LichessInternalDataTypes.
[error]     |              LichessDuelInterna.derived$ReadWriter,
[error]     |            upickle.default.ReadWriter.join[
[error]     |
[error]     |                de.qno.tournamentadmin.lichess.LichessInternalDataTypes.
[error]     |                  LichessDuelInterna
[error]     |
[error]     |            ](
[error]     |              de.qno.tournamentadmin.lichess.LichessInternalDataTypes.
[error]     |                LichessDuelInterna.derived$ReadWriter,
[error]     |              de.qno.tournamentadmin.lichess.LichessInternalDataTypes.
[error]     |                LichessDuelInterna.derived$ReadWriter
[error]     |            )
[error]     |          ),
[error]     |          scala.reflect.ClassTag.apply[
[error]     |
[error]     |              de.qno.tournamentadmin.lichess.LichessInternalDataTypes.
[error]     |                LichessDuelInterna
[error]     |
[error]     |          ](
[error]     |            classOf[
[error]     |              de.qno.tournamentadmin.lichess.LichessInternalDataTypes.
[error]     |                LichessDuelInterna
[error]     |            ]
[error]     |          )
[error]     |        ),
[error]     |        /* ambiguous: both method ArrayWriter in trait Writers and method join in object ReadWriter match type upickle.default.Writer[
[error]     |      Array[
[error]     |        de.qno.tournamentadmin.lichess.LichessInternalDataTypes.LichessDuelInterna]
[error]     |    ] */
[error]     |          summon[
[error]     |            upickle.default.Writer[
[error]     |              Array[
[error]     |                de.qno.tournamentadmin.lichess.LichessInternalDataTypes.
[error]     |                  LichessDuelInterna
[error]     |              ]
[error]     |            ]
[error]     |          ]
[error]     |      ),
[error]     |      upickle.default.ReadWriter.join[
[error]     |
[error]     |          Array[
[error]     |            de.qno.tournamentadmin.lichess.LichessInternalDataTypes.
[error]     |              LichessDuelInterna
[error]     |          ]
[error]     |
[error]     |      ](
[error]     |        /* ambiguous: both method ArrayReader in trait Readers and method join in object ReadWriter match type upickle.default.Reader[
[error]     |      Array[
[error]     |        de.qno.tournamentadmin.lichess.LichessInternalDataTypes.LichessDuelInterna]
[error]     |    ] */
[error]     |          summon[
[error]     |            upickle.default.Reader[
[error]     |              Array[
[error]     |                de.qno.tournamentadmin.lichess.LichessInternalDataTypes.
[error]     |                  LichessDuelInterna
[error]     |              ]
[error]     |            ]
[error]     |          ]
[error]     |        ,
[error]     |        upickle.default.ArrayWriter[
[error]     |          de.qno.tournamentadmin.lichess.LichessInternalDataTypes.LichessDuelInterna
[error]     |          ](
[error]     |          upickle.default.ReadWriter.join[
[error]     |
[error]     |              de.qno.tournamentadmin.lichess.LichessInternalDataTypes.
[error]     |                LichessDuelInterna
[error]     |
[error]     |          ](
[error]     |            upickle.default.ReadWriter.join[
[error]     |
[error]     |                de.qno.tournamentadmin.lichess.LichessInternalDataTypes.
[error]     |                  LichessDuelInterna
[error]     |
[error]     |            ](
[error]     |              de.qno.tournamentadmin.lichess.LichessInternalDataTypes.
[error]     |                LichessDuelInterna.derived$ReadWriter,
[error]     |              de.qno.tournamentadmin.lichess.LichessInternalDataTypes.
[error]     |                LichessDuelInterna.derived$ReadWriter
[error]     |            ),
[error]     |            de.qno.tournamentadmin.lichess.LichessInternalDataTypes.
[error]     |              LichessDuelInterna.derived$ReadWriter
[error]     |          )
[error]     |        )
[error]     |      )
[error]     |    )
[error]     |
[error]     |But both method ArrayWriter in trait Writers and method join in object ReadWriter match type upickle.default.Writer[
[error]     |  Array[
[error]     |    de.qno.tournamentadmin.lichess.LichessInternalDataTypes.LichessDuelInterna]
[error]     |].

I'm not sure if i understand this. For me, it reads: I found 2 ways to construct the ReadWriter, so i used none.

Most probably, that error comes from my lack of experience with Scala and upickle. Any RTFM?

I do not dare to shorten the error message, but stackoverflow will not allow me to submit my question with much code and few text. So i have to add some lines about my project. Not necessery to read.

I’m writing a software that will automate the announcement of my team's upcoming tournaments on lichess and their results. Messages are sent by the internal lichess messages and several social media; atm Xwitter and Bluesky are implemented, Threads and Mastodon are planned.

Lichess offers a comfortable web API to manage tournaments and get informations. Although the lichess server is written in Scala, there is no Scala library for clients. I have to code at least the needed part myself.

Data sent to the server is normally application/x-www-form-urlencoded, answers received are application/json or application/x-ndjson. I created case classes for every action; if a class contains an object in its parameter list, i create a case class for that object, too. upickle (de-)serializes the case classes to JSON and reverse.

TIA QNo

发布评论

评论列表(0)

  1. 暂无评论