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

Update Guide snippet error #3450

Merged
merged 1 commit into from
Jun 16, 2024
Merged

Conversation

bwignall
Copy link
Contributor

The output on the Guide/Concurrency page currently shows

Stream(1,2,3).merge(Stream.eval(IO { Thread.sleep(200); 4 })).compile.toVector.unsafeRunSync()
// error: Could not find an implicit IORuntime.
// 
// Instead of calling unsafe methods directly, consider using cats.effect.IOApp, which
// runs your IO. If integrating with non-functional code or experimenting in a REPL / Worksheet,
// add the following import:

and the text Oops, we need a cats.effect.ContextShift[IO] in implicit scope..

The text was last updated August 2018, before cats-effect 3, which changed ContextShift. I updated it to refer to IORuntime.

@@ -428,7 +428,7 @@ import cats.effect.IO
Stream(1,2,3).merge(Stream.eval(IO { Thread.sleep(200); 4 })).compile.toVector.unsafeRunSync()
Copy link
Member

Choose a reason for hiding this comment

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

Ugh, this guide is old. There are many things wrong with it. This Thread.sleep should be rewritten as IO.sleep(...).as(4) or something.

Copy link
Member

@armanbilge armanbilge left a comment

Choose a reason for hiding this comment

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

Merging b/c this fix is good and standalone (thanks!). We should cleanup some other things as well.

@armanbilge armanbilge merged commit d45c5d0 into typelevel:main Jun 16, 2024
9 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants