question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support multiple parameter lists for case classes

See original GitHub issue

I’d like to derive a codec for

case class A(x:Int)(y:Int)

implicit val jsonCodec: JsonValueCodec[A] = JsonCodecMaker.make

but multiple parameter lists are not supported:

[error]      'A' hasn't a primary constructor with one parameter list. Please consider using a custom implicitly accessible codec for this type.
[error]      L197:   implicit val jsonCodec: JsonValueCodec[A] = JsonCodecMaker.make

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
plokhotnyukcommented, Jun 5, 2022

@fdietze @cornerman Here is a draft that supports primary constructors with multi-parameter lists: https://github.com/plokhotnyuk/jsoniter-scala/pull/905

Limitations for definitions are:

  • val or var for parameters in non-first parameter lists
  • no default values in non-first parameter lists

For sure your support and any help are welcome! Including GitHub stars and sponsoring 😉

1reaction
plokhotnyukcommented, Jun 6, 2022

@fdietze @cornerman Please peek a release with an initial support of multiple parameter lists in primary constructors: https://github.com/plokhotnyuk/jsoniter-scala/releases/tag/v2.13.29

Next steps will be refactoring of calculation of default values during parsing and adding support of default values for non-first parameter lists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to pattern match a class with multiple argument lists?
Case classes match (and do their other nifty things) only on the first set of parameters: scala> case class A(i: Int)(j: Int) {...
Read more >
Multiple parameter lists - Scala Programming Guidelines
Multiple parameter lists. Scala allows defining multiple parameter lists on methods and classes: def compare(x: Int)(y: Int): Int = x - y case...
Read more >
Multiple Parameter Lists | Tour of Scala
Use cases. Suggested use cases for multiple parameter lists include: Drive type inference. It so happens that in Scala, type inference proceeds one...
Read more >
Mirrors are not generated for Case Classes with multiple ...
For example when deriving a Decoder for a class with multiple parameter lists I want to be able to create an instance of...
Read more >
Multiple Parameter Lists (Currying) - Scala - CWIKI.US
In case of a single functional parameter, like op in the case of foldLeft above, multiple parameter lists allow a concise syntax to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found