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
This throws java.lang.StackOverflowError (code from tests CofreeSuite but with bigger size)
CofreeSuite
val unfoldedHundred: Cofree[Option, Int] = Cofree.unfold[Option, Int](0)(i => if (i == 1000000) None else Some(i + 1)) val cata = Cofree .cata[Option, Int, NonEmptyList[Int]](unfoldedHundred)( (i, lb) => Eval.now(NonEmptyList(i, lb.fold[List[Int]](Nil)(_.toList))) ).value
Eval.defer can easily fix this:
Eval.defer
def cata[F[_], A, B](cof: Cofree[F, A])(folder: (A, F[B]) => Eval[B])(implicit F: Traverse[F]): Eval[B] = F.traverse(cof.tailForced)(c => Eval.defer(cata(c)(folder))).flatMap(folder(cof.head, _))
The text was updated successfully, but these errors were encountered:
fix typelevel#2940
fe3d57c
e131e53
No branches or pull requests
This throws java.lang.StackOverflowError (code from tests
CofreeSuite
but with bigger size)Eval.defer
can easily fix this:The text was updated successfully, but these errors were encountered: