Skip to content

Commit

Permalink
Merge pull request #2834 from ivanlp10n2/fix-console-example
Browse files Browse the repository at this point in the history
Fixed console example
  • Loading branch information
djspiewak authored Feb 21, 2022
2 parents ce22791 + b00f9b1 commit f423ac7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
20 changes: 9 additions & 11 deletions std/js/src/main/scala/cats/effect/std/Console.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,16 @@ import java.nio.charset.Charset
*
* @example
* {{{
* import cats.effect.std.Console
* import cats.effect.kernel.Sync
* import cats.syntax.all._
* import cats.Monad
* import cats.effect.std.Console
* import cats.syntax.all._
*
* implicit val console = Console.sync[F]
*
* def myProgram[F[_]: Console]: F[Unit] =
* for {
* _ <- Console[F].println("Please enter your name: ")
* n <- Console[F].readLine
* _ <- if (n.nonEmpty) Console[F].println("Hello, " + n) else Console[F].errorln("Name is empty!")
* } yield ()
* def myProgram[F[_]: Console: Monad]: F[Unit] =
* for {
* _ <- Console[F].println("Please enter your name: ")
* n <- Console[F].readLine
* _ <- if (n.nonEmpty) Console[F].println("Hello, " + n) else Console[F].errorln("Name is empty!")
* } yield ()
* }}}
*/
trait Console[F[_]] extends ConsoleCrossPlatform[F] {
Expand Down
20 changes: 9 additions & 11 deletions std/jvm/src/main/scala/cats/effect/std/Console.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,16 @@ import java.nio.charset.Charset
*
* @example
* {{{
* import cats.effect.std.Console
* import cats.effect.kernel.Sync
* import cats.syntax.all._
* import cats.Monad
* import cats.effect.std.Console
* import cats.syntax.all._
*
* implicit val console = Console.sync[F]
*
* def myProgram[F[_]: Console]: F[Unit] =
* for {
* _ <- Console[F].println("Please enter your name: ")
* n <- Console[F].readLine
* _ <- if (n.nonEmpty) Console[F].println("Hello, " + n) else Console[F].errorln("Name is empty!")
* } yield ()
* def myProgram[F[_] : Console : Monad]: F[Unit] =
* for {
* _ <- Console[F].println("Please enter your name: ")
* n <- Console[F].readLine
* _ <- if (n.nonEmpty) Console[F].println("Hello, " + n) else Console[F].errorln("Name is empty!")
* } yield ()
* }}}
*/
trait Console[F[_]] extends ConsoleCrossPlatform[F] {
Expand Down

0 comments on commit f423ac7

Please sign in to comment.