Sys.Console
eff ConsoleSourceAn effect used to interact with the console.
Operations
Prints the given string s to the standard err followed by a new line.
Prints the given string s to the standard out followed by a new line.
Definitions
def confirm(p: a, default: { default = Bool }): Bool \ Console + Aef[a] with Formattable[a]§ SourcePrints 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 returns default#default.
Returns default#default if the end of input has been reached.
Handles the Console effect of the given function f.
In other words, re-interprets the Console effect using the IO effect.
def pick(p: a, choices: List[b]): Option[b] \ Console + Aef[a] + Aef[b] with Formattable[a], Formattable[b]§ SourcePrints prompt p followed by a numbered list of options, then reads a selection.
Returns Some(element) if the user enters a valid number, None otherwise.
Returns None if the end of input has been reached.
def pickWith(p: a, choices: List[b]): Option[b] \ Console + Aef[a] + Aef[b] with Formattable[a], Formattable[b]§ SourceLike pick, but re-prompts until the user makes a valid selection.
Returns None if the end of input has been reached.
def readlnWith(p: a, f: String -> Result[String, b]): Option[b] \ Console + Aef[a] with Formattable[a]§ SourcePrints 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.
def readlnWithDefault(p: a, default: String): String \ Console + Aef[a] with Formattable[a]§ SourcePrints prompt p, reads a line, and returns default if the input is empty or whitespace.
Returns default if the end of input has been reached.