Skip to content
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

Enrich the delay scaladoc for IO and Sync #2654

Merged
merged 5 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion core/shared/src/main/scala/cats/effect/IO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -931,13 +931,19 @@ object IO extends IOCompanionPlatform with IOLowPriorityImplicits {

/**
* Suspends a synchronous side effect in `IO`.
* Use [[IO.apply]] if your side effect is not thread-blocking;
* otherwise you should use [[IO.blocking]] or `IO.interruptible`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, the direct link to the IO.interruptible is ambiguous. And it could be fixed only by a fully qualified name. That's too extra, I think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that's annoying. I actually don't know how to do that anyway :)

* depending on the need of the created effect cancelation.
danicheg marked this conversation as resolved.
Show resolved Hide resolved
*
* Alias for `IO.delay(body)`.
* Alias for [[IO.delay]].
*/
def apply[A](thunk: => A): IO[A] = delay(thunk)

/**
* Suspends a synchronous side effect in `IO`.
* Use [[IO.delay]] if your side effect is not thread-blocking;
* otherwise you should use [[IO.blocking]] or `IO.interruptible`
* depending on the need of the created effect cancelation.
*
* Any exceptions thrown by the effect will be caught and sequenced into the `IO`.
*/
Expand Down
6 changes: 4 additions & 2 deletions kernel/shared/src/main/scala/cats/effect/kernel/Sync.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ trait Sync[F[_]] extends MonadCancel[F, Throwable] with Clock[F] with Unique[F]
/**
* The synchronous FFI - lifts any by-name parameter into the `F[_]` context.
*
* Equivalent to `Applicative.pure` for pure expressions, the purpose of this function is to
* suspend side effects in `F`.
* Equivalent to [[Applicative.pure]] for pure expressions, the purpose of this function is to
* suspend side effects in `F`. Use [[Sync.delay]] if your side effect is not thread-blocking;
* otherwise you should use [[Sync.blocking]] or [[Sync.interruptible]]
* depending on the need of the created effect cancelation.
*
* @param thunk
* The side effect which is to be suspended in `F[_]`
Expand Down