-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Foldable
instance for List
breaks substitution
#1716
Comments
It is the use of an iterator in With the default implementation of import cats.instances.list._
import cats.Eval
val numbers = List.range(0, 10)
val result = Foldable[List].foldLeft(numbers, Eval.now(List.empty[Int])) { (eb, a) =>
eb.flatMap(acc => Eval.always(a :: acc))
}
result.value
// List[Int] = List(9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
result.value
// List[Int] = List(9, 8, 7, 6, 5, 4, 3, 2, 1, 0) |
If we change the A potential solution may be @TomasMikula 's #1117. |
@peterneyens shall we schedule #1117 to 1.0.0-MF then? I feel bad that we let it fell through the cracks. |
I've approved #1117. It would be great to get some other reviewers on that. If/when it's merged we probably want to remove |
Yeah, it seems like |
The
Foldable
instance forList
breaks substitution, as the following program demonstrates. The value ofresult.value
differs between the first and subsequent calls.I haven't had time to debug but I suspect it relates to the use of a mutable
ListBuffer
in the implementation oftailRecM
.The text was updated successfully, but these errors were encountered: