Sys.Console
eff ConsoleSourceAn effect used to interact with the console.
Operations
def eprint(s: String): Unit \ Console
SourcePrints the given string s to the standard err.
def eprintln(s: String): Unit \ Console
SourcePrints the given string s to the standard err followed by a new line.
def print(s: String): Unit \ Console
SourcePrints the given string s to the standard out.
def println(s: String): Unit \ Console
SourcePrints the given string s to the standard out followed by a new line.
def readln(): String \ Console
SourceReads a single line from the console.
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.
def handle(f: a -> b \ ef): a -> b \ (ef - Console) + IO
SourceHandles 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.
def pickWith(p: a, choices: List[b]): b \ Console + Aef[a] + Aef[b] with Formattable[a], Formattable[b]
SourceLike pick, but re-prompts until the user makes a valid selection.
def readlnWith(p: a, f: String -> Result[String, b]): 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 v.
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.
@DefaultHandler def runWithIO(f: Unit -> a \ ef): a \ (ef - Console) + IO
SourceRuns the Console effect of the given function f.
In other words, re-interprets the Console effect using the IO effect.