shapeless-guide
shapeless-guide copied to clipboard
genericObjectEncoder does not work
The implicit function genericObjectEncoder
does not work with Coproduct as descibed in the book.
The current definition is as followed:
implicit def genericObjectEncoder[A, H <: HList](
implicit
gen: LabelledGeneric.Aux[A, H],
hEncoder: Lazy[JsonObjectEncoder[H]]
): JsonEncoder[A] =
createObjectEncoder(value => hEncoder.value.encode(gen.to(value)))
To make this work, I have to remove <: HList
.
I do not know why this is the case, but I would love to find out more about it.
Other users reported knownDirectSubclasses
bug, but I do not see this error message.