StdOut
The StdOut module provides functions for writing to standard output. It offers low-level string writing as well as higher-level printing that works with any Kit value.
The print and println functions are available as bare functions.
The StdOut.write and StdOut.write-line functions require the
StdOut. prefix.
Writing Output
StdOut.write "Hello"
StdOut.write " "
StdOut.write "World"
# Output: Hello World
StdOut.write-line "Hello, World!"
StdOut.write-line "Second line"
# Output:
# Hello, World!
# Second line
Printing Values
Prints any Kit value to standard output without adding a newline. Uses the value's
show representation for display.
This is a convenience alias that dispatches to StdOut.write.
print 42
print " "
print [1, 2, 3]
# Output: 42 [1, 2, 3]
Prints any Kit value to standard output followed by a newline. Uses the value's
show representation for display.
This is a convenience alias that dispatches to StdOut.write-line.
println 42
println "Hello"
println [1, 2, 3]
# Output:
# 42
# Hello
# [1, 2, 3]
Output Formatting
Combine print and println with string interpolation for formatted output:
name = "Kit"
version = 1
println "Welcome to ${name} version ${version}!"
# Output: Welcome to Kit version 1!
# Format numbers with specifiers
count = 255
println "Hex: ${count:x}, Binary: ${count:b}"
# Output: Hex: ff, Binary: 11111111
items = ["apple", "banana", "cherry"]
println "Items: ${items}"
# Output: Items: ["apple", "banana", "cherry"]
# Print each item on its own line
items |> each (fn(item) => println " - ${item}")
# Output:
# - apple
# - banana
# - cherry
user = {name: "Alice", age: 30, active: true}
println user
# Output: {name: "Alice", age: 30, active: true}
println "User ${user.name} is ${user.age} years old"
# Output: User Alice is 30 years old