-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reversed order of evaluation of Applicative.ap - will reverse order o…
…f params to ap in 1.0
- Loading branch information
Showing
2 changed files
with
15 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package fs2 | ||
package util | ||
|
||
class TraverseSpec extends Fs2Spec { | ||
|
||
"Traverse" - { | ||
"evaluate effects in left-to-right order" in { | ||
var acc = collection.mutable.ListBuffer[Int]() | ||
val result = Traverse[List].traverse((1 to 5).toList)(n => Task.delay(acc += n)) | ||
result.unsafeRunSync() | ||
acc.toList shouldBe List(1, 2, 3, 4, 5) | ||
} | ||
} | ||
} |
38f31cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to me + 1. Also think you have to fix Task.traverse before merging this, otherwise that will result to reversed order now
38f31cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mpilquist I would probably leave the order of
ap
as is and modifytraverse
instead, for the reasons I gave here about it 'working out nicely' to run function's effects first.