cats.effect.std.Console
See theConsole companion object
Effect type agnostic Console
with common methods to write to and read from the standard
console. Suited only for extremely simple console input and output.
Attributes
- Note:
readLine
is not implemented for Scala.js. On Node.js consider usingfs2.io.stdin
.- Example:
import cats.effect.IO import cats.effect.std.Console def myProgram: IO[Unit] = for { _ <- Console[IO].println("Please enter your name: ") n <- Console[IO].readLine _ <- if (n.nonEmpty) Console[IO].println("Hello, " + n) else Console[IO].errorln("Name is empty!") } yield ()
import cats.Monad import cats.effect.std.Console import cats.syntax.all._ 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 ()
- Companion:
- object
- Source:
- Console.scala
- Graph
- Supertypes
- class Objecttrait Matchableclass Any