We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Consider the following Option-like ADT:
@deriveTraverse sealed abstract class MyExprF[+A] extends Product with Serializable object MyExprF { final case class Const[+A](value: A) extends MyExprF[A] case object Noll extends MyExprF[Nothing] }
The derived traverse method in the Traverse instance throws a MatchError on the Noll case:
traverse
Traverse
MatchError
Noll
scala> import cats.implicits._ import cats.implicits._ scala> val c: MyExprF[Int] = Const(3) c: qq.droste.examples.MyExprF[Int] = Const(3) scala> c.traverse(Option.apply) // expected output res0: Option[qq.droste.examples.MyExprF[Int]] = Some(Const(3)) scala> val n: MyExprF[Int] = Noll n: qq.droste.examples.MyExprF[Int] = Noll scala> n.traverse(Option.apply) // I would expect Some(Noll) scala.MatchError: Noll (of class qq.droste.examples.MyExprF$Noll$) at qq.droste.examples.MyExprF$$anon$1.traverse(TestExpr.scala:6) at qq.droste.examples.MyExprF$$anon$1.traverse(TestExpr.scala:6) at cats.Traverse$Ops.traverse(Traverse.scala:19) at cats.Traverse$Ops.traverse$(Traverse.scala:19) at cats.Traverse$ToTraverseOps$$anon$3.traverse(Traverse.scala:19) ... 36 elided
The text was updated successfully, but these errors were encountered:
Add count
ec96323
This required implementing my own Traverse instance. See [this issue](higherkindness#72).
@ceedubs thanks for the report! the derivation code is not very polished yet, so this kind of examples help a lot.
I'll try to put some work into it soon!
Sorry, something went wrong.
pepegar
No branches or pull requests
Consider the following Option-like ADT:
The derived
traverse
method in theTraverse
instance throws aMatchError
on theNoll
case:The text was updated successfully, but these errors were encountered: