Skip to content

5.3.2 Instances for concrete products H is constrained to HList in genericObjectEncoder #61

@jo-wil

Description

@jo-wil

The function

import shapeless.LabelledGeneric
implicit def genericObjectEncoder[A, H <: HList]( // <--- this is where I think <: HList should be removed
  implicit
  generic: LabelledGeneric.Aux[A, H],
  hEncoder: Lazy[JsonObjectEncoder[H]]
): JsonEncoder[A] =
  createObjectEncoder { value =>
    hEncoder.value.encode(generic.to(value))
}

has the type constraint H <: HList which I think is too constrained. This works fine for the product IceCream example but in the coproduct Shape example, Scala can't find an implicit encoder since Coproduct is not an HList.

Please let me know if this is a problem or if there is a better way to do this. I just removed <: HList from my code on the H parameter and then everything worked as described.

If this is an issue I can fix it and file a pull request as well just let me know.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions