6.66. kink/io/PRINTER

Companion mod for printers.

6.66.1. type printer

`printer` is an output port of strings.

`printer` provides sequential forward operations to the underlying destination.

Example

6.66.1.1. Printer.print(Str ...[$config={}])

`print` writes `Str`.

• C.on_success($success): default = {}

• C.on_error($error): default = a fun which raises an exception

If `Str` is written without an IO error, `print` tail-calls $success with no arg.

If an IO error occurs, `print` tail-calls $error with an `exception`.

Preconditions

`Str` must be a `str`

$success must be a fun which takes no arg

$error must be a fun which takes an `exception`

Example

Example: IO error

6.66.1.2. Printer.print_line(Str ...[$config={}])

`print_line` writes `Str` and `newline`.

• C.on_success($success): default = {}

• C.on_error($error): default = a fun which raises an exception

If `Str` and `newline` are written without an IO error, `print_line` tail-calls $success with no arg.

If an IO error occurs, `print_line` tail-calls $error with an `exception`.

Preconditions

`Str` must be a `str`

$success must be a fun which takes no arg

$error must be a fun which takes an `exception`

Example

Example: IO error

6.66.1.3. Printer.newline

`newline` returns a `str` of the newline used by `print_line`.

6.66.2. PRINTER.is?(Val)

`is?` returns whether `Val` is a `printer`.

6.66.3. PRINTER.mixin

`mixin` returns a mixin trait which provides Printer.print_line method.

`print_line` will be implemented using `newline` and `print` methods.