// types — error union, mode/whence enums, reader/writer/closer // fn-type aliases. Project #94 fold-1 step (d) (drew Fold D). // // Hare splits the io module across stream.ha + types.ha and ww does // the same: lib/io/io.ww owns the (pre-vtable) `stream`, `eof`, and // `underread` shapes; this file owns the surrounding port. Both // files share `package io;` so forward refs (e.g. reader → stream) // resolve via the dir-enum concat order. // // Deferrals (drew-signed): `handle`, `seeker`, `copier`, `strerror` // land with fold-e (need the `handle` sum). Hare's `EOF = done` // stays as `io.eof` until the `done` singleton ships (#93). package io; // ref/hare/io/types.ha:29-34. RDWR is spelled `3` rather than Hare's // `READ | WRITE` because the ww parser doesn't fold expressions in // enum value positions; the value SSoT stays the same bitfield. export type mode = enum u8 { NONE = 0, READ = 1, WRITE = 2, RDWR = 3, }; // ref/hare/io/types.ha:37-41. Hare leaves the underlying implicit; // ww requires one. i32 matches the off type that fold-e will plug // into the seeker signature. export type whence = enum i32 { SET = 0, CUR = 1, END = 2, }; // ref/hare/io/types.ha:11 spreads `errors::error` into the union; // lib/errors isn't ported yet, so the union carries only the tags // observable in this fold — `underread` (from io.ww) and the // predeclared `nomem` (#29, type.c:72 / check.ww:78). export type error = !(underread | nomem); // ref/hare/io/types.ha:46. `eof` (not Hare's `done`) per the io.ww:8 // rationale; lifts to `done` with #93. `*stream` forward-refs the // pre-vtable struct in io.ww — same cross-file pattern Hare uses. export type reader = fn(s: *stream, buf: []u8) (size | eof | error); // ref/hare/io/types.ha:51. No `const` qualifier — ww has none, and // lib/io/io.ww:30 + lib/sort/sort.ww:18 drop it the same way. export type writer = fn(s: *stream, buf: []u8) (size | error); // ref/hare/io/types.ha:55. export type closer = fn(s: *stream) (void | error);