lib+test: unify errors to Hare named-void tagged-union

Five tags from ref/hare/errors/common.ha — invalid, noaccess, noentry,
exists, unsupported — all !void. lib/io keeps eof/closed as plain void
(no Hare analogue for ww's singleton-style done) and adds underread.
Drops errors.equal/isnil and the old str-sentinel surface.
This commit is contained in:
2026-05-13 20:19:03 +09:00
parent 388ab8a707
commit 2243849855
4 changed files with 71 additions and 45 deletions

View File

@@ -5,14 +5,23 @@
// value of read/write/close — Hare-shaped tagged unions instead of
// errno-style integer sentinels.
// eof — read past the end of the stream. NAMED-void so it's a
// distinct variant tag from `void` (which would be "no result yet").
// eof — read past the end of the stream. Hare uses the `done`
// singleton for EOF; ww doesn't have `done` yet so we ship a
// named-void variant tag.
export type eof = void;
// closed — operation attempted on a stream that has already been
// closed. NAMED-void; same shape, different tag.
// closed. ww-specific: Hare's io collapses this into the wider
// errors union, but our stream vtable has no handle-ownership
// semantics, so a distinct tag is honest. Named void.
export type closed = void;
// underread — an I/O handle hit eof partway through a fixed-size
// read. Payload is the byte count actually delivered. Mirrors
// Hare's `io::underread = !size`; ww uses i32 because the
// underlying buffer-length type is i32 today.
export type underread = !i32;
export type stream = struct {
ctx: *void,
read: fn(s: *stream, buf: []u8) (i32 | eof | closed),