Skip to content

Can't infer PBWriter for recursive Coproducts #31

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

Open
vovapolu opened this issue Mar 5, 2019 · 0 comments
Open

Can't infer PBWriter for recursive Coproducts #31

vovapolu opened this issue Mar 5, 2019 · 0 comments

Comments

@vovapolu
Copy link

vovapolu commented Mar 5, 2019

For example I want infer pbdirect instances for the following sealed trait:

import pbdirect._

sealed trait MyList

case class Cons(i: Int, l: MyList) extends MyList
case object Nil extends MyList

PBWriter[MyList] // error: could not find implicit value for evidence parameter of type pbdirect.PBWriter[MyList]
PBReader[MyList] // ok

PBReader is inferred just fine, but PBWriter is not.

My guess is that it should be tail: Lazy[PBWriter[T]] in implicit def cconsWriter instead of just tail: PBWriter[T]

implicit def cconsWriter[H, T <: Coproduct](
      implicit head: PBWriter[H],
      tail: PBWriter[T]): PBWriter[H :+: T] // it should be Lazy[PBWriter[T]]

just as it's implemented for PBReader

implicit def cconsParser[H, T <: Coproduct](
      implicit
      head: PBParser[H],
      tail: Lazy[PBParser[T]]): PBParser[H :+: T]
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