Results for “how do I read a file”

30 results, best first

  1. packagePackages › audio Reading and writing …encode(a, container, fmt): [int]!AErr writes a complete file. container reads writes WAV (RIFF, RF64) PCM u8/s16/s24/s32 (also 12/20-bit in wider containers), float 32/64, A-law, μ-law, IMA ADPCM, MS…
  2. error codeError codes E0100: dependency or file not found …in raft.toml isn't installed under .raft/, or a source file of the program couldn't be read. Auk resolves every path (geo.area) at compile time, so a missing package is reported up front instead of…
  3. packagePackages › splash Linked stylesheets and static files fn read_static(name: str): str? uses fs = match fs.read("static/{name}") { ok(text) => some(text) err(_) => none } fn handle(req: http.server.Req): http.Resp uses fs { match splash.static(req, f =>…
  4. definitionReference › Glossary effect Something a function does to the world outside the program: reading a file (fs), using the network (net), reading the clock (time). A function lists its effects after uses, so its first line tells…
  5. The language Effects …str): int = text.split().len() // pure fn count_file(path: str): int! uses fs = word_count(fs.read(path)?) // reads a file fn main(args: [str]): ()! uses fs { print(count_file(args[1])?) }
  6. The language › Errors and optionals Errors: T! …up and then call something on the value, parenthesize: (fs.read(p)?).len(). x?.f() is optional chaining, which is for T? only. The compiler does not let an error vanish. Using a T! where a T is…
  7. Start here › A tour of Auk 4. The outside world Reading a file is an effect, and functions that have effects declare them: struct Item { name: str, qty: int, price: float } fn parse_item(line: str): Item! { let [name, qty, price] = line.split(",")…
  8. The language › Calling C Special prototypes …between ffi.Ptr and an extern type "#embed logo.png" the file's contents, read at compile time and stored in the program (the path is relative to the source file). The result type picks the form:…
  9. The language › Effects The effects effect allows core module fs reading and writing files and directories fs net sockets, TLS, listening net time the clock and sleeping time rand random numbers rand env environment variables,…
  10. The language › Effects Effects bound a whole project …│ └── encoding 0.1.0 └── csv 0.1.0 Here you know, without reading a line of their code, that json, url, encoding and csv cannot open a file or a socket, and that no update to them ever can without…
  11. Reference Package catalog …default registry. Add one with raft add <name>. Each has a README.md with its full API. The "effects" column is the most a package can do. A package with none is pure computation: it cannot touch…
  12. packagePackages audio …and encodes WAV, AIFF/AIFC, AU and FLAC, and probes files. It resamples, remixes channels, filters (biquads, EQ, echo, compressor, limiter, gate, fades, time stretch, pitch shift), measures (stats,…
  13. packagePackages csv Reads and writes RFC 4180 CSV. It handles quoted fields, doubled quotes (""), commas and line breaks inside quotes, and CRLF, LF or lone-CR line endings. It returns rows as [[str]] or, when the file…
  14. Working on Auk › Compiler architecture Pipeline …tokens AST modules, types, explicit structured └─▶ object file + libauk_rt.a ─▶ ld (link) ─▶ native exe (build) names patterns, RC/control C-like IR effects, flow shapes Written in Auk. The compiler…
  15. Working on Auk › Compiler architecture Source layout file contents compiler/src/main.auk, drive.auk, cli.auk, posix.auk, embedded.auk the auk CLI: command dispatch; drive: check, generate, JIT run, build, traces, project roots, forked children; cli:…
  16. Working on Auk › Compiler architecture Runtime ABI (runtime/c/auk_rt.h is the source of truth) …children). They're atomic because async tasks run on threads. str: an immutable UTF-8 buffer with a byte length, a cached char count and an is_ascii flag. Char indexing is O(1) when ASCII. Interning…
  17. Working on Auk › Low-level Auk (raw) 7a. As implemented (Phase 7a): what differs, and the details the sections above leave open …_setjmp/_longjmp (§7), not the sjlj intrinsics. raw thread var needs compiled code: the JIT (auk run, auk test) links without a platform runtime and has no thread-local storage, so it refuses a…
  18. Working on Auk › Low-level Auk (raw) 10. Blocks without -fblocks (Network.framework) …initializer yet (E0421); nothing these blocks are given to reads it. Layout (64-bit; what Clang emits today, checked with -emit-llvm): raw struct BlockHdr { // every block starts with this isa:…
  19. Working on Auk › Low-level Auk (raw) 11. Targets: per-OS code and the C headers' facts …compilation in the language; instead: Per-target files (raw packages only): beside os.auk a module may have os.macos.auk, os.linux.auk, os.linux-arm64.auk, … The resolver loads the most specific one…
  20. Working on Auk › raft design notes Core vs packages …the invoker hands the program, so no separate effect): env.read_line(): str? (none at end of input), env.read_all(): str!, env.lines(): [str]. proc.exit(code: int): never uses proc ends the program…
  21. Working on Auk › raft design notes raft.lock …"sha256:9f2c…" The checksum is SHA-256 over the installed files (raft.toml, README.md if present, src/**), in sorted relative-path order using / separators. Each file contributes its path, a NUL…
  22. Working on Auk › raft design notes Bundles …A bundle is exactly the checksum input above (each file's path, NUL, 8-byte big-endian length, contents, in sorted path order), so its SHA-256 is the lock checksum, which pack prints. raft unpacks…
  23. Reference › Core library fs (uses fs) fs.read(path): str!, fs.write(path, text): ()!, fs.append(path, text): ()! whole files, as text fs.lines(path): [str]! fs.read_bytes(path): [int]!, fs.write_bytes(path, bytes): ()! bytes are ints 0…
  24. Reference › Cheat sheet C functions …*)". A prototype "#embed path" (C23's directive) is a file read at compile time, kept in the program (the path is relative to the source file); the result is its bytes as [int], its text as str…
  25. Tools › Auk with AI agents What an agent should use …auk spec the whole language in about 180 dense lines; read it first Check a change auk check <file> --json diagnostics with codes, exact spans and fix-it edits Understand an error auk explain E0xxx a…
  26. Tools › Testing and debugging Interactive mode …(auk) run command run, r start the program break, b <file:line|fn> set a breakpoint; break <place> if <cond> for a condition delete, d [id] remove one breakpoint, or all continue, c resume next, n /…
  27. Tools › Editors VS Code …The source is in its own repository, auk-vscode, whose README covers building it yourself. It finds auk on the PATH or in ~/.auk/bin; the setting auk.path names another binary. What you get:…
  28. Tools › Editors Any other editor …evaluate Point your editor's LSP client at auk lsp for files matching *.auk, with the project root at the nearest raft.toml. For format-on-save without LSP, pipe the buffer through auk fmt -. A DAP…
  29. Tools › raft, the package manager Serving packages from a URL raft pack writes a package as one file, <name>.raft, holding raft.toml, README.md and src/. Put it on any web server (a static host, a release page, an object store): $ cd geo && raft pack…
  30. Tools › raft, the package manager Writing a package …items are the package's API, reached as geo.<item>; other files are submodules (src/shapes.auk is geo.shapes). Declare the smallest effects list you can. A package with none can be added to any…