-
Notifications
You must be signed in to change notification settings - Fork 520
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
adds more details to random.md documentation #3792
base: series/3.5.x
Are you sure you want to change the base?
Conversation
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.
This is great! Can we retarget at series/3.5.x though so it gets out sooner?
911d23f
to
6a4dcfe
Compare
docs/std/random.md
Outdated
|
||
// use the standard implementation of Random backed by java.util.Random() | ||
// (the same implementation as Random.javaUtilRandom(43)) | ||
implicit val r: IO[Random[IO]] = Random.scalaUtilRandom[IO] |
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.
Is having an implicit IO[A]
a common pattern? I don't think I've ever seen it. I would expect an implicit Random[IO]
here (but of course that opens the question of "should Random
be passed implicitly").
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.
I agree this seems odd and it doesn't make sense in this context why it's used implicitly. I changed it to be an explicit param.
docs/std/random.md
Outdated
|
||
// for testing, create a Random instance that gives back the same number every time. With | ||
// this version of the Random type class, we can test our business logic works as intended. | ||
implicit val r: IO[Random[IO]] = IO( |
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.
implicit val r: IO[Random[IO]] = IO( | |
implicit val r: IO[Random[IO]] = IO.pure( |
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.
ah. yup.
docs/std/random.md
Outdated
implicit val r: IO[Random[IO]] = IO( | ||
new Random[IO] { | ||
def betweenInt(minInclusive: Int, maxExclusive: Int): IO[Int] = | ||
IO(7) // gives back 7 every call |
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.
IO(7) // gives back 7 every call | |
IO.pure(7) // gives back 7 every call |
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.
double yup
Looks like the build failures are legitimate |
sorry, I don't get what I need to do to fix this issue. Can someone point me the right direction? |
Looks like import errors. Use Do you know how to run it locally? Thanks for your work! |
docs/std/random.md
Outdated
import cats.effect.std.Random | ||
import cats.syntax.all |
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.
import cats.syntax.all | |
import cats.syntax.all._ |
I feel we should retain the example of using
I would like to expand this example into a working copy-and-paste example. This example at current state does not show how |
Adds more detailed documentation for the
Random
type, including a unit test example.