shapeless-guide icon indicating copy to clipboard operation
shapeless-guide copied to clipboard

genericObjectEncoder does not work

Open khanetor opened this issue 7 years ago • 2 comments

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.

khanetor avatar May 29 '17 23:05 khanetor