POLYTONE — the AI-native programming language

Guide

The whole filesystem

Since Sprint 346 the Fs capability lists, creates, appends and deletes — beside read and write.

tidy.pt
fn main(disk: Fs) -> Void:
    match disk.mkdir("logs/2026"):
        case Ok(made):
            print("created: {made}")
        case Err(e):
            print(e)
    for line in ["start", "stop"]:
        match disk.append("logs/2026/run.txt", "{line}\n".to_bytes()):
            case Ok(n):
                print("appended {n} bytes")
            case Err(e):
                print(e)
    print("{disk.list_dir("logs/2026")}")
    print("{disk.exists("logs")} {disk.is_dir("logs/2026/run.txt")}")
    print("refused while not empty: {disk.delete("logs").is_err()}")
    print("{disk.delete("logs/2026/run.txt")} {disk.delete("logs/2026")} {disk.delete("logs")}")

list_dir returns sorted names; mkdir creates the parents and answers whether the directory was new; delete removes a file or an EMPTY directory and answers whether something was there — never recursively, so the first delete of logs above is refused. A mock_fs(files) answers all of them from its map, deterministically.