trait Console[F[_]] extends ConsoleCrossPlatform[F]

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 in trivial applications.

Source
Console.scala
Examples:
  1. 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 ()
  2. ,
  3. 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 ()
Linear Supertypes
ConsoleCrossPlatform[F], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Console
  2. ConsoleCrossPlatform
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract def error[A](a: A)(implicit S: Show[A] = Show.fromToString[A]): F[Unit]

    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.

    a

    value to be printed to the standard error output

    S

    implicit cats.Show[A] instance, defaults to cats.Show.fromToString

    Definition Classes
    Console → ConsoleCrossPlatform
  2. abstract def errorln[A](a: A)(implicit S: Show[A] = Show.fromToString[A]): F[Unit]

    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.

    a

    value to be printed to the standard error output

    S

    implicit cats.Show[A] instance, defaults to cats.Show.fromToString

    Definition Classes
    Console → ConsoleCrossPlatform
  3. abstract def print[A](a: A)(implicit S: Show[A] = Show.fromToString[A]): F[Unit]

    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.

    a

    value to be printed to the standard output

    S

    implicit cats.Show[A] instance, defaults to cats.Show.fromToString

    Definition Classes
    Console → ConsoleCrossPlatform
  4. abstract def println[A](a: A)(implicit S: Show[A] = Show.fromToString[A]): F[Unit]

    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.

    a

    value to be printed to the standard output

    S

    implicit cats.Show[A] instance, defaults to cats.Show.fromToString

    Definition Classes
    Console → ConsoleCrossPlatform
  5. abstract def readLineWithCharset(charset: Charset): F[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.

    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 Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  9. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. def mapK[G[_]](f: ~>[F, G]): Console[G]

    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

    Definition Classes
    Console → ConsoleCrossPlatform
  13. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. def printStackTrace(t: Throwable): F[Unit]

    Prints the stack trace of the given Throwable to standard error output.

    Prints the stack trace of the given Throwable to standard error output.

    Definition Classes
    Console → ConsoleCrossPlatform
  17. def readLine: F[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

  18. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  19. def toString(): String
    Definition Classes
    AnyRef → Any
  20. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  21. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  22. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from ConsoleCrossPlatform[F]

Inherited from AnyRef

Inherited from Any

Ungrouped