Effect type agnostic Console
with common methods to write to and read from the standard
console. Due to issues around cancellation in readLine
, suited only for extremely simple
console input and output in trivial applications.
Attributes
- 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
Members list
Value members
Abstract methods
Prints a value to the standard error output using the implicit cats.Show
instance.
Prints a value to the standard error output using the implicit cats.Show
instance.
Attributes
- S
implicit
cats.Show[A]
instance, defaults tocats.Show.fromToString
- a
value to be printed to the standard error output
- Source:
- Console.scala
Prints a value to the standard error output using the implicit cats.Show
instance.
Prints a value to the standard error output using the implicit cats.Show
instance.
Attributes
- S
implicit
cats.Show[A]
instance, defaults tocats.Show.fromToString
- a
value to be printed to the standard error output
- Source:
- Console.scala
Prints a value to the standard error output followed by a new line using the implicit
cast.Show
instance.
Prints a value to the standard error output followed by a new line using the implicit
cast.Show
instance.
Attributes
- S
implicit
cats.Show[A]
instance, defaults tocats.Show.fromToString
- a
value to be printed to the standard error output
- Source:
- Console.scala
Prints a value to the standard error output followed by a new line using the implicit
cast.Show
instance.
Prints a value to the standard error output followed by a new line using the implicit
cast.Show
instance.
Attributes
- S
implicit
cats.Show[A]
instance, defaults tocats.Show.fromToString
- a
value to be printed to the standard error output
- Source:
- Console.scala
Prints a value to the standard output using the implicit cats.Show
instance.
Prints a value to the standard output using the implicit cats.Show
instance.
Attributes
- S
implicit
cats.Show[A]
instance, defaults tocats.Show.fromToString
- a
value to be printed to the standard output
- Source:
- Console.scala
Prints a value to the standard output using the implicit cats.Show
instance.
Prints a value to the standard output using the implicit cats.Show
instance.
Attributes
- S
implicit
cats.Show[A]
instance, defaults tocats.Show.fromToString
- a
value to be printed to the standard output
- Source:
- Console.scala
Prints a value to the standard output followed by a new line using the implicit cats.Show
instance.
Prints a value to the standard output followed by a new line using the implicit cats.Show
instance.
Attributes
- S
implicit
cats.Show[A]
instance, defaults tocats.Show.fromToString
- a
value to be printed to the standard output
- Source:
- Console.scala
Prints a value to the standard output followed by a new line using the implicit cats.Show
instance.
Prints a value to the standard output followed by a new line using the implicit cats.Show
instance.
Attributes
- S
implicit
cats.Show[A]
instance, defaults tocats.Show.fromToString
- a
value to be printed to the standard output
- Source:
- Console.scala
Reads a line as a string from the standard input using the provided charset.
Reads a line as a string from the standard input using the provided charset.
The effect can raise a java.io.EOFException
if no input has been consumed before the EOF
is observed. This should never happen with the standard input, unless it has been replaced
with a finite java.io.InputStream
through java.lang.System#setIn
or similar.
Attributes
- charset
the
java.nio.charset.Charset
to be used when decoding the input stream- Returns:
an effect that describes reading the user's input from the standard input as a string
- Source:
- Console.scala
Reads a line as a string from the standard input using the provided charset.
Reads a line as a string from the standard input using the provided charset.
The effect can raise a java.io.EOFException
if no input has been consumed before the EOF
is observed. This should never happen with the standard input, unless it has been replaced
with a finite java.io.InputStream
through java.lang.System#setIn
or similar.
Attributes
- charset
the
java.nio.charset.Charset
to be used when decoding the input stream- Returns:
an effect that describes reading the user's input from the standard input as a string
- Source:
- Console.scala
Concrete methods
Modifies the context in which this console operates using the natural transformation f
.
Modifies the context in which this console operates using the natural transformation f
.
Attributes
- Returns:
a console in the new context obtained by mapping the current one using
f
- Source:
- Console.scala
Modifies the context in which this console operates using the natural transformation f
.
Modifies the context in which this console operates using the natural transformation f
.
Attributes
- Returns:
a console in the new context obtained by mapping the current one using
f
- Source:
- Console.scala
Prints the stack trace of the given Throwable to standard error output.
Prints the stack trace of the given Throwable to standard error output.
Attributes
- Source:
- Console.scala
Prints the stack trace of the given Throwable to standard error output.
Prints the stack trace of the given Throwable to standard error output.
Attributes
- Source:
- Console.scala
Reads a line as a string from the standard input using the platform's default charset, as
per java.nio.charset.Charset.defaultCharset()
.
Reads a line as a string from the standard input using the platform's default charset, as
per java.nio.charset.Charset.defaultCharset()
.
The effect can raise a java.io.EOFException
if no input has been consumed before the EOF
is observed. This should never happen with the standard input, unless it has been replaced
with a finite java.io.InputStream
through java.lang.System#setIn
or similar.
Attributes
- Returns:
an effect that describes reading the user's input from the standard input as a string
- Source:
- Console.scala
Reads a line as a string from the standard input using the platform's default charset, as
per java.nio.charset.Charset.defaultCharset()
.
Reads a line as a string from the standard input using the platform's default charset, as
per java.nio.charset.Charset.defaultCharset()
.
The effect can raise a java.io.EOFException
if no input has been consumed before the EOF
is observed. This should never happen with the standard input, unless it has been replaced
with a finite java.io.InputStream
through java.lang.System#setIn
or similar.
Attributes
- Returns:
an effect that describes reading the user's input from the standard input as a string
- Source:
- Console.scala