-
Notifications
You must be signed in to change notification settings - Fork 597
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
Introduced Suspendable type class #710
Merged
Merged
Conversation
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 PR moves `suspend` and `delay` from the `Effect` type class to a new `Suspendable` type class. There are two motivations for doing this: - Exposing `unsafeRunAsync` to any function that requires `suspend` or `delay` gives up a lot of parametricity. - Some type constructors have `Suspendable` instances but do not support value extraction. This came up in the [port of Doobie to FS2](typelevel/doobie#323 (comment)). This [came up on Gitter a while back as well](http://www.gitterforum.com/discussion/scalaz-scalaz-stream?page=143).
@@ -108,14 +108,15 @@ val eff = Stream.eval(Task.delay { println("TASK BEING RUN!!"); 1 + 1 }) | |||
|
|||
[`Task`](../core/shared/src/main/scala/fs2/Task.scala) is an effect type we'll see a lot in these examples. Creating a `Task` has no side effects, and `Stream.eval` doesn't do anything at the time of creation, it's just a description of what needs to happen when the stream is eventually interpreted. Notice the type of `eff` is now `Stream[Task,Int]`. | |||
|
|||
The `eval` function works for any effect type, not just `Task`. FS2 does not care what effect type you use for your streams. You may use the included [`Task` type][Task] for effects or bring your own, just by implementing a few interfaces for your effect type ([`Catchable`][Catchable] and optionally [`Effect`][Effect] or [`Async`][Async] if you wish to use various concurrent operations discussed later). Here's the signature of `eval`: | |||
The `eval` function works for any effect type, not just `Task`. FS2 does not care what effect type you use for your streams. You may use the included [`Task` type][Task] for effects or bring your own, just by implementing a few interfaces for your effect type ([`Catchable`][Catchable], [`Suspendable`][Suspendable], [`Effect`][Effect], and optional [`Async`][Async] if you wish to use various concurrent operations discussed later). Here's the signature of `eval`: |
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.
"optionally Async
", not "optional Async
"
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.
Thanks, fixed
👍 |
lgtm |
👍 |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR moves
suspend
anddelay
from theEffect
type class to anew
Suspendable
type class. There are two motivations for doing this:unsafeRunAsync
to any function that requiressuspend
or
delay
gives up a lot of parametricity.Suspendable
instances but do notsupport value extraction. This came up in the port of Doobie to
FS2.
This came up on Gitter a while back as
well.
/cc @tpolecat @guersam