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.
- Example
import cats.effect.std.Console import cats.effect.kernel.Sync 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 ()
- Companion
- object
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.
- Value Params
- S
implicit
cats.Show[A]
instance, defaults tocats.Show.fromToString
- a
value to be printed to the standard error output
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.
- Value Params
- S
implicit
cats.Show[A]
instance, defaults tocats.Show.fromToString
- a
value to be printed to the standard error output
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.
- Value Params
- S
implicit
cats.Show[A]
instance, defaults tocats.Show.fromToString
- a
value to be printed to the standard error output
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.
- Value Params
- S
implicit
cats.Show[A]
instance, defaults tocats.Show.fromToString
- a
value to be printed to the standard error output
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.
- Value Params
- S
implicit
cats.Show[A]
instance, defaults tocats.Show.fromToString
- a
value to be printed to the standard output
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.
- Value Params
- S
implicit
cats.Show[A]
instance, defaults tocats.Show.fromToString
- a
value to be printed to the standard output
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.
- Value Params
- S
implicit
cats.Show[A]
instance, defaults tocats.Show.fromToString
- a
value to be printed to the standard output
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.
- Value Params
- S
implicit
cats.Show[A]
instance, defaults tocats.Show.fromToString
- a
value to be printed to the standard output
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.
- Value Params
- 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
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.
- Value Params
- 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
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
.
- Returns
a console in the new context obtained by mapping the current one using
f
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
.
- Returns
a console in the new context obtained by mapping the current one using
f
Prints the stack trace of the given Throwable to standard error output.
Prints the stack trace of the given Throwable to standard error output.
Prints the stack trace of the given Throwable to standard error output.
Prints the stack trace of the given Throwable to standard error output.
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.
- Returns
an effect that describes reading the user's input from the standard input as a string
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.
- Returns
an effect that describes reading the user's input from the standard input as a string