Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
fix var/laziness bug in Foldable[List]
- Loading branch information
Showing
with
5 additions
and
1 deletion.
-
+5
−1
core/src/main/scala/scalaz/std/List.scala
|
|
@@ -64,7 +64,11 @@ trait ListInstances extends ListInstances0 { |
|
|
val s = new ArrayStack[A] |
|
|
fa.foreach(a => s += a) |
|
|
var r = z |
|
|
while (!s.isEmpty) {r = f(s.pop, r)} |
|
|
while (!s.isEmpty) { |
|
|
// force and copy the value of r to ensure correctness |
|
|
val w = r |
|
|
r = f(s.pop, w) |
|
|
} |
|
|
r |
|
|
} |
|
|
|
|
|
|