Skip to content

Console Domain

The Console domain is your program's voice. It handles basic interactions with the terminal. Whether you're debugging with a quick print, logging a status update, or asking the user for input, this is where your program talks to the human running it.

aivi
use aivi.console

Functions

FunctionExplanation
log message
String -> Effect Unit
Prints message to standard output with a trailing newline.
println message
String -> Effect Unit
Alias for log.
print message
String -> Effect Unit
Prints message without a trailing newline.
error message
String -> Effect Unit
Prints message to standard error.
readLine 😦)
Unit -> Effect (Result String Error)
Reads a line from standard input.
color color text
AnsiColor -> Text -> Text
Wraps text in ANSI foreground color codes.
bgColor color text
AnsiColor -> Text -> Text
Wraps text in ANSI background color codes.
style style text
AnsiStyle -> Text -> Text
Applies multiple ANSI attributes to text.
strip text
Text -> Text
Removes ANSI escape sequences from text.

ANSI Types

aivi
type AnsiColor = Black | Red | Green | Yellow | Blue | Magenta | Cyan | White | Default

type AnsiStyle = {
  fg: Option AnsiColor
  bg: Option AnsiColor
  bold: Bool
  dim: Bool
  italic: Bool
  underline: Bool
  blink: Bool
  inverse: Bool
  hidden: Bool
  strike: Bool
}