Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jo-wil opened this issue Feb 22, 2018 · 0 comments

Comments

@jo-wil
Copy link

jo-wil commented Feb 22, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant