Does shapeless provide a type class/macro that summons a HList containing the default values for all parameters of a case class?
Let's say we have this case class:
case class User(name: String, age: Int = 18)
Then I would like to get such a HList:
None :: Some(() => 18) :: HNil
Default parameters is implemented over synthetic methods. Try it trait. https://github.com/milessabin/shapeless/blob/master/core/src/main/scala/shapeless/default.scala
import shapeless.Default
case class User(name: String, age: Int = 18)
val d = Default[User]
println(d())
Out:
None :: Some(18) :: HNil
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With