Console
eff ConsoleSourceEffect for interacting with the console.
The operations are the interface that a handler implements.
Programs normally use print, println, eprint, and eprintln
which accept any value with a ToString instance.
Effect for interacting with the console, and its functions.
Default Handler
Operations
Reads a single line from the console.
Returns None if the end of input has been reached.
Writes the given string s to the standard err followed by a new line.
Definitions
Prints prompt p with a yes/no hint and reads a boolean answer.
Appends [Y/n] if default#default is true, or [y/N] if false.
Empty input returns default#default. Recognizes "y", "yes", "n", "no" (case-insensitive).
Any other input prints an error to stderr and re-prompts.
Returns default#default if the end of input has been reached.
Prints the string representation of x to the standard err.
Prints the string representation of x to the standard err followed by a new line.
Handles the Console effect of the given function f.
In other words, re-interprets the Console effect using the IO effect.
Prints the string representation of x to the standard out.
Prints the string representation of x to the standard out followed by a new line.
def readlnAs(p: a): Option[b] \ Console with ToString[a], FromString[b]§ SourcePrints prompt p, reads a line, and parses it as a value of type b.
Leading and trailing whitespace is ignored.
If the input cannot be parsed, prints an error to stderr and re-prompts.
Returns None if the end of input has been reached.
Prints prompt p, reads a line, and applies f to the input.
If f returns Err(msg), prints msg to stderr and re-prompts.
If f returns Ok(v), returns Some(v).
Returns None if the end of input has been reached.