shithub: mc

Download patch

ref: 8672ce0c95bf5d6e6b721694bd0e5944d4af556b
parent: 7cc7912b2834f9f5dde95412e5302f13fb82042c
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Sep 30 18:18:21 EDT 2017

Replace bio.status(@t) with std.result(@t, bio.err)

	It's more consistent.

--- a/lib/bio/bio.myr
+++ b/lib/bio/bio.myr
@@ -33,19 +33,12 @@
 		close	: (-> bool)
 	;;
 
-	type status(@a) = union
+	type err = union
 		`Eof
-		`Ok @a
-		`Err ioerr
+		`Eio
+		`Ebadf
 	;;
 
-	type ioerr = union
-		`Ebadfile
-		`Ebadbuf
-		`Ebadfd
-		`Eioerr
-	;;
-
 	/* creation */
 	const mkfile	: (fd : std.fd, mode : mode	-> file#)
 	const mk	: (mode : mode, vt : vtab	-> file#)
@@ -56,36 +49,36 @@
 	const free	: (f : file# -> void)
 
 	/* basic i/o. Returns sub-buffer when applicable. */
-	const write	: (f : file#, src : byte[:]	-> status(std.size))
-	const read	: (f : file#, dst : byte[:]	-> status(byte[:]))
+	const write	: (f : file#, src : byte[:]	-> std.result(std.size, err))
+	const read	: (f : file#, dst : byte[:]	-> std.result(byte[:], err))
 	const flush	: (f : file# -> bool)
 
 	/* seeking */
-	const seek	: (f : file#, off : std.off -> std.result(std.off, ioerr))
+	const seek	: (f : file#, off : std.off -> std.result(std.off, err))
 
 	/* single unit operations */
-	const putb	: (f : file#, b : byte	-> status(std.size))
-	const putc	: (f : file#, c : char	-> status(std.size))
-	const getb	: (f : file# -> status(byte))
-	const getc	: (f : file# -> status(char))
+	const putb	: (f : file#, b : byte	-> std.result(std.size, err))
+	const putc	: (f : file#, c : char	-> std.result(std.size, err))
+	const getb	: (f : file# -> std.result(byte, err))
+	const getc	: (f : file# -> std.result(char, err))
 
 	/* peeking */
-	const peekb	: (f : file# -> status(byte))
-	const peekc	: (f : file# -> status(char))
+	const peekb	: (f : file# -> std.result(byte, err))
+	const peekc	: (f : file# -> std.result(char, err))
 
 	/* delimited read; returns freshly allocated buffer. */
-	const readln	: (f : file#	-> status(byte[:]))
-	const readto	: (f : file#, delim : byte[:]	-> status(byte[:]))
+	const readln	: (f : file#	-> std.result(byte[:], err))
+	const readto	: (f : file#, delim : byte[:]	-> std.result(byte[:], err))
 	const skipto	: (f : file#, delim : byte[:]	-> bool)
 	const skipspace	: (f : file# -> bool)
 
 	/* formatted i/o */
-	const put	: (f : file#, fmt : byte[:], args : ... -> status(std.size))
-	const putv	: (f : file#, fmt : byte[:], ap : std.valist# -> status(std.size))
+	const put	: (f : file#, fmt : byte[:], args : ... -> std.result(std.size, err))
+	const putv	: (f : file#, fmt : byte[:], ap : std.valist# -> std.result(std.size, err))
 
 	/* pkg funcs */
-	pkglocal const ensureread	: (f : file#, n : std.size -> status(std.size))
-	pkglocal const ensurewrite	: (f : file#, n : std.size -> status(std.size))
+	pkglocal const ensureread	: (f : file#, n : std.size -> std.result(std.size, err))
+	pkglocal const ensurewrite	: (f : file#, n : std.size -> std.result(std.size, err))
 ;;
 
 const Bufsz = 16*std.KiB
@@ -208,7 +201,7 @@
 	if src.len <= (f.wbuf.len - f.wend)
 		std.slcp(f.wbuf[f.wend:f.wend+src.len], src)
 		f.wend += src.len
-		-> `Ok src.len
+		-> `std.Ok src.len
 	else
 		flush(f)
 		-> writebuf(f, src)
@@ -225,7 +218,7 @@
 
 	/* Clear the error state so we can retry */
 	if f.lasterr != 0
-		-> `Err geterr(f)
+		-> `std.Err geterr(f)
 	;;
 
 	/*
@@ -235,7 +228,7 @@
 	an EOF condition.
 	*/
 	if dst.len == 0
-		-> `Ok dst
+		-> `std.Ok dst
 	;;
 	std.assert(f.mode & Rd != 0, "File is not in read mode")
 	/* 
@@ -268,7 +261,7 @@
 			d = d[n:]
 		| `std.Err err:
 			if count == 0
-				-> `Err errtype(err)
+				-> `std.Err errtype(err)
 			else
 				f.lasterr = err
 			;;
@@ -276,9 +269,9 @@
 		;;
 	;;
 	if count == 0
-		-> `Eof
+		-> `std.Err `Eof
 	else
-		-> `Ok dst[:count]
+		-> `std.Ok dst[:count]
 	;;
 }
 
@@ -289,7 +282,7 @@
 	ret = true
 	if f.mode & Wr != 0
 		match writebuf(f, f.wbuf[:f.wend])
-		| `Ok n: ret = (n == f.wend)
+		| `std.Ok n: ret = (n == f.wend)
 		| _:	ret = false
 		;;
 	;;
@@ -309,11 +302,10 @@
 /* writes a single byte to the output stream */
 const putb = {f, b
 	match ensurewrite(f, 1)
-	| `Eof: -> `Eof
-	| `Err e:	-> `Err e
-	| `Ok n:
+	| `std.Err e:	-> `std.Err e
+	| `std.Ok n:
 		f.wbuf[f.wend++] = b
-		-> `Ok 1
+		-> `std.Ok 1
 	;;
 }
 
@@ -323,12 +315,11 @@
 	
 	sz = std.charlen(c)
 	match ensurewrite(f, sz)
-	| `Eof: -> `Eof
-	| `Err e:	-> `Err e
-	| `Ok n:
+	| `std.Err e:	-> `std.Err e
+	| `std.Ok n:
 		std.encode(f.wbuf[f.wend:], c)
 		f.wend += sz
-		-> `Ok sz
+		-> `std.Ok sz
 	;;
 }
 
@@ -335,10 +326,9 @@
 /* reads a single byte from the input stream */
 const getb = {f
 	match ensureread(f, 1)
-	| `Eof:	-> `Eof
-	| `Err e:	-> `Err e
-	| `Ok n:
-		-> `Ok f.rbuf[f.rstart++]
+	| `std.Err e:	-> `std.Err e
+	| `std.Ok n:
+		-> `std.Ok f.rbuf[f.rstart++]
 	;;
 }
 
@@ -347,12 +337,11 @@
 	var c
 
 	match ensurecodepoint(f)
-	| `Eof:	-> `Eof
-	| `Err e:	-> `Err e
-	| `Ok n:
+	| `std.Err e:	-> `std.Err e
+	| `std.Ok n:
 		c = std.decode(f.rbuf[f.rstart:f.rend])
 		f.rstart += std.charlen(c)
-		-> `Ok c
+		-> `std.Ok c
 	;;
 }
 
@@ -362,9 +351,8 @@
 	var len
 
 	match ensureread(f, 1)
-	| `Eof:	-> `Eof
-	| `Err e:	-> `Err e
-	| `Ok n:
+	| `std.Err e:	-> `std.Err e
+	| `std.Ok n:
 		b = f.rbuf[f.rstart]
 		if b & 0x80 == 0	/* 0b0xxx_xxxx */
 			len = 1
@@ -408,10 +396,9 @@
 /* peeks a single byte from an input stream */
 const peekb = {f
 	match ensureread(f, 1)
-	| `Eof:	-> `Eof
-	| `Err e:	-> `Err e
-	| `Ok n:
-		-> `Ok f.rbuf[f.rstart]
+	| `std.Err e:	-> `std.Err e
+	| `std.Ok n:
+		-> `std.Ok f.rbuf[f.rstart]
 	;;
 }
 
@@ -418,10 +405,9 @@
 /* peeks a single character from a utf8 encoded input stream */
 const peekc = {f
 	match ensurecodepoint(f)
-	| `Eof:	-> `Eof
-	| `Err e:	-> `Err e
-	| `Ok n:
-		-> `Ok std.decode(f.rbuf[f.rstart:f.rend])
+	| `std.Err e:	-> `std.Err e
+	| `std.Ok n:
+		-> `std.Ok std.decode(f.rbuf[f.rstart:f.rend])
 	;;
 }
 
@@ -441,9 +427,8 @@
 /* same as readto, but drops the read data. */
 const skipto = {f, delim
 	match readdelim(f, delim, true)
-	| `Ok ign:	-> true
-	| `Eof:		-> false
-	| `Err _:		-> false
+	| `std.Ok ign:	-> true
+	| `std.Err _:		-> false
 	;;
 }
 
@@ -450,14 +435,12 @@
 const skipspace = {f
 	while true
 		match bio.peekc(f)
-		| `Ok c:
+		| `std.Ok c:
 			if !std.isspace(c)
 				break
 			;;
 			bio.getc(f)
-		| `Err e:	-> false
-		| `Eof: break
-		
+		| `std.Err e:		-> false
 		;;
 	;;
 	-> true
@@ -471,15 +454,15 @@
 	while true
 		/* get at least delimiter count of characters */
 		match ensureread(f, 1)
-		| `Ok _:
-		| `Err e:	-> `Err e
-		| `Eof:
+		| `std.Err `Eof:
 			ret = readinto(f, ret, f.rend - f.rstart)
 			if ret.len > 0
-				-> `Ok ret
+				-> `std.Ok ret
 			else
-				-> `Eof
+				-> `std.Err `Eof
 			;;
+		| `std.Err e:	-> `std.Err e
+		| `std.Ok _:
 		;;
 		/* scan for delimiter */
 		for var i = f.rstart; i < f.rend; i++
@@ -491,7 +474,7 @@
 				if c == '\r' && unwrapc(peekc(f), -1) == '\n'
 					f.rstart++
 				;;
-				-> `Ok ret
+				-> `std.Ok ret
 			;;
 :nextitergetln
 		;;
@@ -502,7 +485,7 @@
 
 const unwrapc = {cc, v
 	match cc
-	| `Ok c:	-> c
+	| `std.Ok c:	-> c
 	| _:	-> v
 	;;
 }
@@ -514,17 +497,17 @@
 	while true
 		/* get at least delimiter count of characters */
 		match ensureread(f, 1)
-		| `Ok _:
-		| `Err e:	-> `Err e
-		| `Eof:
+		| `std.Err `Eof:
 			if !drop
 				ret = readinto(f, ret, f.rend - f.rstart)
 			;;
 			if ret.len > 0
-				-> `Ok ret
+				-> `std.Ok ret
 			else
-				-> `Eof
+				-> `std.Err `Eof
 			;;
+		| `std.Err e:	-> `std.Err e
+		| `std.Ok _:
 		;;
 		for var i = f.rstart; i < f.rend; i++
 			if f.rbuf[i] == delim[0]
@@ -537,7 +520,7 @@
 					ret = readinto(f, ret, i - f.rstart)
 				;;
 				f.rstart += delim.len
-				-> `Ok ret
+				-> `std.Ok ret
 			;;
 :nextiterread
 		;;
@@ -591,14 +574,13 @@
 	std.assert(n < f.wbuf.len, "ensured write capacity > buffer size")
 	if n > f.wbuf.len - f.wend
 		match writebuf(f, f.wbuf[:f.wend])
-		| `Ok len:
+		| `std.Ok len:
 			f.wend = 0
-			-> `Ok len
-		| `Err e: -> `Err e
-		| `Eof: -> `Eof
+			-> `std.Ok len
+		| `std.Err e: -> `std.Err e
 		;;
 	;;
-	-> `Ok n
+	-> `std.Ok n
 }
 
 /*
@@ -612,17 +594,16 @@
 	held = f.rend - f.rstart
 	if n > held
 		match fill(f, n)
-		| `Eof:	-> `Eof
-		| `Err e:	-> `Err e
-		| `Ok len:
+		| `std.Err e:	-> `std.Err e
+		| `std.Ok len:
 			if len >= n
-				-> `Ok len
+				-> `std.Ok len
 			else
-				-> `Eof
+				-> `std.Err `Eof
 			;;
 		;;
 	else
-		-> `Ok n
+		-> `std.Ok n
 	;;
 }
 
@@ -634,16 +615,16 @@
 	while src.len != 0
 		match f.write(src)
 		| `std.Ok 0:
-			-> `Eof
+			-> `std.Err `Eof
 		| `std.Ok n:
 			count += n
 			src = src[n:]
 		| `std.Err e:
-			-> `Err errtype(e)
+			-> `std.Err errtype(e)
 		;;
 	;;
 :writedone
-	-> `Ok count
+	-> `std.Ok count
 }
 
 
@@ -658,7 +639,7 @@
 	count = 0
 	/* Clear the error state so we can retry */
 	if f.lasterr != 0
-		-> `Err geterr(f)
+		-> `std.Err geterr(f)
 	;;
 
 	/* if we need to shift the slice down to the start, do it */
@@ -684,7 +665,7 @@
 			if count > 0
 				f.lasterr = e
 			else
-				-> `Err errtype(e)
+				-> `std.Err errtype(e)
 			;;
 			break
 		;;
@@ -691,9 +672,9 @@
 	;;
 
 	if count == 0
-		-> `Eof
+		-> `std.Err `Eof
 	else
-		-> `Ok count
+		-> `std.Ok count
 	;;
 }
 
@@ -705,20 +686,18 @@
 	-> errtype(e)
 }
 
-const errtype = {e : std.errno -> ioerr
+const errtype = {e : std.errno -> err
 	var errno
 
 	errno = (e : std.errno)
 	if errno == std.Ebadf
-		-> `Ebadfile
+		-> `Ebadf
 	elif errno == std.Einval
-		-> `Ebadfile
+		-> `Ebadf
 	elif errno == std.Efault
-		-> `Ebadbuf
-	elif errno == std.Eio
-		-> `Eioerr
+		-> `Eio
 	else
-		-> `Eioerr
+		-> `Eio
 	;;
 }
 
--- a/lib/bio/geti.myr
+++ b/lib/bio/geti.myr
@@ -4,16 +4,16 @@
 
 pkg bio =
 	/* unsigned big endian */
-	generic getbe8	: (f : file# -> status(@a::(numeric,integral)))
-	generic getbe16	: (f : file# -> status(@a::(numeric,integral)))
-	generic getbe32	: (f : file# -> status(@a::(numeric,integral)))
-	generic getbe64	: (f : file# -> status(@a::(numeric,integral)))
+	generic getbe8	: (f : file# -> std.result(@a::(numeric,integral), err))
+	generic getbe16	: (f : file# -> std.result(@a::(numeric,integral), err))
+	generic getbe32	: (f : file# -> std.result(@a::(numeric,integral), err))
+	generic getbe64	: (f : file# -> std.result(@a::(numeric,integral), err))
 
 	/* signed big endian */
-	generic getle8	: (f : file# -> status(@a::(numeric,integral)))
-	generic getle16	: (f : file# -> status(@a::(numeric,integral)))
-	generic getle32	: (f : file# -> status(@a::(numeric,integral)))
-	generic getle64	: (f : file# -> status(@a::(numeric,integral)))
+	generic getle8	: (f : file# -> std.result(@a::(numeric,integral), err))
+	generic getle16	: (f : file# -> std.result(@a::(numeric,integral), err))
+	generic getle32	: (f : file# -> std.result(@a::(numeric,integral), err))
+	generic getle64	: (f : file# -> std.result(@a::(numeric,integral), err))
 ;;
 
 /*
@@ -20,18 +20,18 @@
   reads a single integer-like value to the output stream, in
   little endian format
 */
-generic getle = {f, n -> status(@a::(numeric,integral))
+generic getle = {f, n -> std.result(@a::(numeric,integral), err)
 	var v, i
 
 	v = 0
 	match ensureread(f, n)
-	| `Eof:	-> `Eof
-	| `Err e :	-> `Err e
-	| `Ok _:
+	| `std.Err e:
+		-> `std.Err e
+	| `std.Ok _:
 		for i = 0; i < n; i++
 			v |= (f.rbuf[f.rstart++] : uint64) << (8*(i : uint64))
 		;;
-		-> `Ok (v : @a::(numeric,integral))
+		-> `std.Ok (v : @a::(numeric,integral))
 	;;
 }
 
@@ -39,19 +39,19 @@
   reads a single integer-like value to the output stream, in
   big endian format
 */
-generic getbe = {f, n -> status(@a::(numeric,integral))
+generic getbe = {f, n -> std.result(@a::(numeric,integral), err)
 	var v, i
 
 	v = 0
 	match ensureread(f, n)
-	| `Eof:	-> `Eof
-	| `Err e :	-> `Err e
-	| `Ok _:
+	| `std.Err e:
+		-> `std.Err e
+	| `std.Ok _:
 		for i = 0; i < n; i++
 			v <<= 8
 			v |= (f.rbuf[f.rstart++] : uint64)
 		;;
-		-> `Ok (v : @a::(numeric,integral))
+		-> `std.Ok (v : @a::(numeric,integral))
 	;;
 }
 
--- a/lib/bio/iter.myr
+++ b/lib/bio/iter.myr
@@ -18,9 +18,8 @@
 impl iterable lineiter -> byte[:] =
 	__iternext__ = {itp, outp
 		match bio.readln((itp# : file#))
-		| `Ok ln:	outp# = ln
-		| `Err _:	-> false
-		| `Eof:		-> false
+		| `std.Ok ln:	outp# = ln
+		| `std.Err _:	-> false
 		;;
 		-> true
 	}
@@ -37,9 +36,8 @@
 impl iterable chariter -> char =
 	__iternext__ = {itp, outp : char#
 		match bio.getc((itp# : file#))
-		| `Ok c:	outp# = c
-		| `Err _:	-> false
-		| `Eof:		-> false
+		| `std.Ok c:	outp# = c
+		| `std.Err _:	-> false
 		;;
 		-> true
 	}
--- a/lib/bio/puti.myr
+++ b/lib/bio/puti.myr
@@ -4,16 +4,16 @@
 
 pkg bio =
 	/* unsigned big endian */
-	generic putbe8	: (f : file#, v : @a::(numeric,integral) -> status(std.size))
-	generic putbe16	: (f : file#, v : @a::(numeric,integral) -> status(std.size))
-	generic putbe32	: (f : file#, v : @a::(numeric,integral) -> status(std.size))
-	generic putbe64	: (f : file#, v : @a::(numeric,integral) -> status(std.size))
+	generic putbe8	: (f : file#, v : @a::(numeric,integral) -> std.result(std.size, err))
+	generic putbe16	: (f : file#, v : @a::(numeric,integral) -> std.result(std.size, err))
+	generic putbe32	: (f : file#, v : @a::(numeric,integral) -> std.result(std.size, err))
+	generic putbe64	: (f : file#, v : @a::(numeric,integral) -> std.result(std.size, err))
 
 	/* unsigned little endian */
-	generic putle8	: (f : file#, v : @a::(numeric,integral) -> status(std.size))
-	generic putle16	: (f : file#, v : @a::(numeric,integral) -> status(std.size))
-	generic putle32	: (f : file#, v : @a::(numeric,integral) -> status(std.size))
-	generic putle64	: (f : file#, v : @a::(numeric,integral) -> status(std.size))
+	generic putle8	: (f : file#, v : @a::(numeric,integral) -> std.result(std.size, err))
+	generic putle16	: (f : file#, v : @a::(numeric,integral) -> std.result(std.size, err))
+	generic putle32	: (f : file#, v : @a::(numeric,integral) -> std.result(std.size, err))
+	generic putle64	: (f : file#, v : @a::(numeric,integral) -> std.result(std.size, err))
 ;;
 
 generic putbe8  = {f, v; -> putbe(f, (v : uint64), 1)}
@@ -30,9 +30,9 @@
 	var buf : byte[8]
 
 	match ensurewrite(f, n)
-	| `Eof:	-> `Eof
-	| `Err e:	-> `Err e
-	| `Ok _:
+	| `std.Err e:
+		-> `std.Err e
+	| `std.Ok _:
 		buf[0] = ((v >> 0) & 0xff : byte)
 		buf[1] = ((v >> 8) & 0xff : byte)
 		buf[2] = ((v >> 16) & 0xff : byte)
@@ -49,9 +49,9 @@
 	var buf : byte[8]
 
 	match ensurewrite(f, n)
-	| `Eof:	-> `Eof
-	| `Err e:	-> `Err e
-	| `Ok _:
+	| `std.Err e:
+		-> `std.Err e
+	| `std.Ok _:
 		buf[0] = ((v >> 56) & 0xff : byte)
 		buf[1] = ((v >> 48) & 0xff : byte)
 		buf[2] = ((v >> 40) & 0xff : byte)
--- a/lib/bio/test/bio-delim.myr
+++ b/lib/bio/test/bio-delim.myr
@@ -67,11 +67,11 @@
 
 const readln = {f
 	match bio.readln(f)
-	| `bio.Ok d:	-> d
-	| `bio.Eof:
+	| `std.Ok d:	-> d
+	| `std.Err `bio.Eof:
 		std.put("eof\n")
 		-> [][:]
-	| `bio.Err e:
+	| `std.Err e:
 		std.put("err\n")
 		-> [][:]
 	;;
@@ -79,11 +79,11 @@
 
 const readto = {f, delim
 	match bio.readto(f, delim)
-	| `bio.Ok d:	-> d
-	| `bio.Eof:
+	| `std.Ok d:	-> d
+	| `std.Err `bio.Eof:
 		std.put("eof\n")
 		-> [][:]
-	| `bio.Err e:
+	| `std.Err e:
 		std.put("err\n")
 		-> [][:]
 	;;
--- a/lib/bio/test/bio-endianrd.myr
+++ b/lib/bio/test/bio-endianrd.myr
@@ -1,13 +1,6 @@
 use std
 use bio
 
-generic try = {opt : bio.status(@a::(integral,numeric))-> @a::(integral,numeric)
-	match opt
-	| `bio.Ok val:	-> val
-	| _: std.fatal("read failed")
-	;;
-}
-
 const main = {
 	var b : byte
 	var w : uint16
@@ -23,31 +16,31 @@
 	
 	/* byte */
 	b = 0xaa
-	var r = try(bio.getle8(f))
+	var r = std.try(bio.getle8(f))
 	std.assert(r == b, "le byte broken: {x}\n", r)
-	std.assert(try(bio.getbe8(f)) == b, "be byte broken\n")
+	std.assert(std.try(bio.getbe8(f)) == b, "be byte broken\n")
 
 	/* word */
 	w = 0xaabb
-	std.assert(try(bio.getle16(f)) == w, "le word broken\n")
-	std.assert(try(bio.getbe16(f)) == w, "be word broken\n")
+	std.assert(std.try(bio.getle16(f)) == w, "le word broken\n")
+	std.assert(std.try(bio.getbe16(f)) == w, "be word broken\n")
 
 	/* long */
 	l = 0xaabbccdd
-	std.assert(try(bio.getle32(f)) == l, "le long broken\n")
-	std.assert(try(bio.getbe32(f)) == l, "be long broken\n")
+	std.assert(std.try(bio.getle32(f)) == l, "le long broken\n")
+	std.assert(std.try(bio.getbe32(f)) == l, "be long broken\n")
 
 	/* quad */
 	q = (0x11223344aabbccdd : uint64)
-	std.assert(try(bio.getle64(f)) == q, "le quad broken\n")
-	std.assert(try(bio.getbe64(f)) == q, "be quad broken\n")
+	std.assert(std.try(bio.getle64(f)) == q, "le quad broken\n")
+	std.assert(std.try(bio.getbe64(f)) == q, "be quad broken\n")
 
 	/* end of file */
 	match bio.getle64(f)
-	| `bio.Eof:
-	| `bio.Err _:
+	| `std.Err `bio.Eof:
+	| `std.Err _:
 		std.die("error on reading file\n")
-	| `bio.Ok v:
+	| `std.Ok v:
 		std.die("read past end of file\n")
 		v = q /* shut up type inference */
 	;;
--- a/lib/bio/test/bio-peek.myr
+++ b/lib/bio/test/bio-peek.myr
@@ -28,11 +28,11 @@
 
 const peekc = {f
 	match bio.peekc(f)
-	| `bio.Ok c:	-> c
-	| `bio.Eof:
+	| `std.Ok c:	-> c
+	| `std.Err `bio.Eof:
 		std.put("eof\n")
 		-> -1
-	| `bio.Err e:
+	| `std.Err e:
 		std.fatal("error reading\n")
 		-> -1
 	;;
@@ -40,11 +40,11 @@
 
 const peekb = {f
 	match bio.peekb(f)
-	| `bio.Ok b:	-> b
-	| `bio.Eof:
+	| `std.Ok b:	-> b
+	| `std.Err `bio.Eof:
 		std.put("eof\n")
 		-> -1
-	| `bio.Err e:
+	| `std.Err e:
 		std.fatal("error reading\n")
 		-> -1
 	;;
--- a/lib/bio/test/bio-read.myr
+++ b/lib/bio/test/bio-read.myr
@@ -40,12 +40,12 @@
 
 const r = {f, buf
 	match bio.read(f, buf)
-	| `bio.Ok b:
+	| `std.Ok b:
 		-> b
-	| `bio.Eof:
+	| `std.Err `bio.Eof:
 		std.put("eof\n")
 		-> ""
-	| `bio.Err e:
+	| `std.Err e:
 		std.put("err\n")
 		-> ""
 	;;
--- a/lib/bio/test/mem.myr
+++ b/lib/bio/test/mem.myr
@@ -7,7 +7,7 @@
 
 	f = bio.mkmem("hello world")
 	match bio.read(f, buf[:3])
-	| `bio.Ok "hel":
+	| `std.Ok "hel":
 		/* ok */
 	| _:
 		std.fatal("invalid read from memfile")
@@ -14,7 +14,7 @@
 	;;
 
 	match bio.read(f, buf[:])
-	| `bio.Ok "lo world":
+	| `std.Ok "lo world":
 		/* ok */
 	| _:
 		std.fatal("invalid read from memfile")
@@ -21,7 +21,7 @@
 	;;
 
 	match bio.read(f, buf[:])
-	| `bio.Eof:
+	| `std.Err `bio.Eof:
 		/* ok */
 	| _:
 		std.fatal("expected eof in memfile")
--- a/lib/http/client.myr
+++ b/lib/http/client.myr
@@ -180,9 +180,8 @@
 
 	buf = std.slalloc(r.len)
 	match bio.read(s.f, buf)
-	| `bio.Err e:	goto shortread
-	| `bio.Eof:	goto shortread
-	| `bio.Ok rd:
+	| `std.Err e:	goto shortread
+	| `std.Ok rd:
 		if rd.len != r.len
 			goto shortread
 		;;
@@ -215,13 +214,10 @@
 		| `std.Ok sz:
 			std.slgrow(&buf, buf.len + sz)
 			match bio.read(s.f, buf[len:len + sz])
-			| `bio.Eof:
+			| `std.Err e:
 				std.slfree(buf)
-				-> `std.Err `Eshort
-			| `bio.Err e:
-				std.slfree(buf)
 				-> `std.Err `Econn
-			| `bio.Ok str:
+			| `std.Ok str:
 				if str.len != sz
 					std.slfree(buf)
 					-> `std.Err `Eshort
@@ -243,9 +239,8 @@
 	var r
 
 	match bio.readln(s.f)
-	| `bio.Err e:	r = `std.Err `Econn
-	| `bio.Eof:	r = `std.Err `Econn
-	| `bio.Ok crlf:
+	| `std.Err e:	r = `std.Err `Econn
+	| `std.Ok crlf:
 		if std.strstrip(crlf).len == 0
 			r = `std.Ok void
 		else
--- a/lib/http/parse.myr
+++ b/lib/http/parse.myr
@@ -23,13 +23,10 @@
 	])
 
 	match bio.readln(s.f)
-	| `bio.Err e:
+	| `std.Err e:
 		err = `Econn
 		goto error
-	| `bio.Eof:	
-		err = `Econn
-		goto error
-	| `bio.Ok ln:
+	| `std.Ok ln:
 		match parsereqstatus(s, r, ln)
 		| `std.Ok void:
 		| `std.Err e:
@@ -42,13 +39,10 @@
 
 	while true
 		match bio.readln(s.f)
-		| `bio.Err e:	
+		| `std.Err e:	
 			err = `Econn
 			goto error
-		| `bio.Eof:
-			err = `Econn
-			goto error
-		| `bio.Ok ln:
+		| `std.Ok ln:
 			if std.strstrip(ln).len == 0
 				std.slfree(ln)
 				break
@@ -70,9 +64,8 @@
 
 const parseresp = {s, r : resp#
 	match bio.readln(s.f)
-	| `bio.Err e:	r.err = `std.Some `Econn
-	| `bio.Eof:	r.err = `std.Some `Econn
-	| `bio.Ok ln:
+	| `std.Err _:	r.err = `std.Some `Econn
+	| `std.Ok ln:
 		if !parserespstatus(s, r, ln)
 			std.slfree(ln)
 			-> false
@@ -82,9 +75,8 @@
 
 	while true
 		match bio.readln(s.f)
-		| `bio.Err e:	r.err = `std.Some `Econn
-		| `bio.Eof:	r.err = `std.Some `Econn
-		| `bio.Ok ln:
+		| `std.Err e:	r.err = `std.Some `Econn
+		| `std.Ok ln:
 			if std.strstrip(ln).len == 0
 				std.slfree(ln)
 				break
@@ -203,9 +195,8 @@
 	var ret, str
 
 	match bio.readln(s.f)
-	| `bio.Eof:	ret = `std.Err `Econn
-	| `bio.Err e:	ret = `std.Err `Econn
-	| `bio.Ok ln:
+	| `std.Err e:	ret = `std.Err `Econn
+	| `std.Ok ln:
 		str = ln
 		match parsenumber(&str, 16)
 		| `std.Some n:	ret = `std.Ok (n : std.size)
--- a/lib/http/session.myr
+++ b/lib/http/session.myr
@@ -58,9 +58,8 @@
 	;;
 	ap = std.vastart(&args)
 	match bio.putv(s.f, fmt, &ap)
-	| `bio.Ok _:	/* nothing */
-	| `bio.Err _:	s.err = true
-	| `bio.Eof:	s.err = true
+	| `std.Ok _:	/* nothing */
+	| `std.Err _:	s.err = true
 	;;
 	-> s.err
 }
@@ -70,9 +69,8 @@
 		-> false
 	;;
 	match bio.write(s.f, buf)
-	| `bio.Ok _:	/* nothing */
-	| `bio.Err _:	s.err = true
-	| `bio.Eof:	s.err = true
+	| `std.Ok _:	/* nothing */
+	| `std.Err _:	s.err = true
 	;;
 	-> s.err
 }
--- a/lib/inifile/parse.myr
+++ b/lib/inifile/parse.myr
@@ -54,13 +54,13 @@
 	f = bio.mkfile(fd, bio.Rd)
 	while true
 		match bio.readln(f)
-		| `bio.Eof:
+		| `std.Err `bio.Eof:
 			break
-		| `bio.Ok ln:
+		| `std.Ok ln:
 			if !parseline(p, ini, ln)
 				break
 			;;
-		| `bio.Err e:
+		| `std.Err e:
 			p.err = `std.Some `Fileerr
 			break
 		;;
--- a/lib/inifile/write.myr
+++ b/lib/inifile/write.myr
@@ -53,7 +53,7 @@
 
 		val = std.htgetv(ini.elts, (sect, key), "")
 		match bio.put(f, "\t{} = {}\n", key, val)
-		| `bio.Err e: -> false
+		| `std.Err e: -> false
 		| _:
 		;;
 	;;
--- a/lib/regex/redump.myr
+++ b/lib/regex/redump.myr
@@ -57,12 +57,12 @@
 const dump = {re, fd 
 	while true
 		match bio.readln(fd)
-		| `bio.Ok ln:
+		| `std.Ok ln:
 			show(re, ln, regex.exec(re, ln))
 			std.slfree(ln)
-		| `bio.Eof:
+		| `std.Err `bio.Eof:
 			break
-		| `bio.Err e:
+		| `std.Err e:
 			std.put("error reading from input: {}", e)
 			break
 		;;
--- a/mbld/libs.myr
+++ b/mbld/libs.myr
@@ -55,16 +55,14 @@
 
 	(f, dir) = openlib(lib, targ, incs)
 	match bio.getc(f)
-	| `bio.Ok 'U':	/* ok */
-	| `bio.Ok _:	std.fput(1, "{}/{}: not a usefile\n", dir, lib)
-	| `bio.Err e:	std.fatal("{}/{}: error reading: {}\n", dir, lib, e)
-	| `bio.Eof:	std.fatal("{}/{}: truncated\n", dir, lib)
+	| `std.Ok 'U':	/* ok */
+	| `std.Ok _:	std.fput(1, "{}/{}: not a usefile\n", dir, lib)
+	| `std.Err e:	std.fatal("{}/{}: error reading: {}\n", dir, lib, e)
 	;;
 	match bio.getbe32(f)
-	| `bio.Ok Abiversion:	/* nothing: version matches. */
-	| `bio.Ok v:	std.fput(1, "{}/{}: mismatched abi {}\n", dir, lib, v)
-	| `bio.Err e:	std.fatal("{}/{}: error reading: {}\n", dir, lib, e)
-	| `bio.Eof:	std.fatal("{}/{}: truncated\n", dir, lib)
+	| `std.Ok Abiversion:	/* nothing: version matches. */
+	| `std.Ok v:	std.fput(1, "{}/{}: mismatched abi {}\n", dir, lib, v)
+	| `std.Err e:	std.fatal("{}/{}: error reading: {}\n", dir, lib, e)
 	;;
 	std.slfree(rdstr(f))
 
@@ -72,10 +70,10 @@
 	dyndep = [][:]
 	while true
 		match bio.getc(f)
-		| `bio.Ok 'L':	std.slpush(&dep, rdstr(f))
-		| `bio.Ok 'X':	std.slpush(&dyndep, rdstr(f))
-		| `bio.Err e:	std.fatal("{}: error reading {}", lib, e)
-		| _:		break;
+		| `std.Ok 'L':	std.slpush(&dep, rdstr(f))
+		| `std.Ok 'X':	std.slpush(&dyndep, rdstr(f))
+		| `std.Err e:	std.fatal("{}: error reading {}\n", lib, e)
+		| _:		break
 		;;
 	;;
 	bio.close(f)
@@ -179,11 +177,10 @@
 	var sl
 
 	match bio.getbe32(f)
-	| `bio.Ok l:
+	| `std.Ok l:
 		len = l
 		sl = std.slalloc(len)
-	| `bio.Eof:	std.fatal("end of file while reading string")
-	| `bio.Err e:	std.fatal("error while reading string: {}", e)
+	| `std.Err e:	std.fatal("error while reading string: {}", e)
 	;;
 	bio.read(f, sl)
 	-> sl
--- a/mbld/subtest.myr
+++ b/mbld/subtest.myr
@@ -29,9 +29,11 @@
 	log = bio.mkfile(logfd, bio.Wr)
 	res = `std.None
 	match bio.readln(f)
-	| `bio.Err e:	std.fatal("error reading subfile: {}\n", e)
-	| `bio.Eof:	-> `std.None
-	| `bio.Ok ln:
+	| `std.Err `bio.Eof:
+		-> `std.None
+	| `std.Err e:
+		std.fatal("error reading subfile: {}\n", e)
+	| `std.Ok ln:
 		match testplan(ln)
 		| `std.None:
 			bio.write(log, ln)
--- a/support/dumpleak.myr
+++ b/support/dumpleak.myr
@@ -50,11 +50,11 @@
 const dump = {path, f, stats
 	while true
 		match bio.getle64(f)
-		| `bio.Ok 0:	tracealloc(path, f, stats)
-		| `bio.Ok 1:	tracefree(path, f, stats)
-		| `bio.Eof:	break
-		| `bio.Ok wat:	std.fatal("unknown action type {x}\n", wat)
-		| `bio.Err e:	std.fatal("failed to read {}: {}\n", path, e)
+		| `std.Err `bio.Eof:	break
+		| `std.Ok 0:		tracealloc(path, f, stats)
+		| `std.Ok 1:		tracefree(path, f, stats)
+		| `std.Ok wat:		std.fatal("unknown action type {x}\n", wat)
+		| `std.Err e:		std.fatal("failed to read {}: {}\n", path, e)
 		;;
 	;;
 	if !summary
@@ -116,7 +116,7 @@
 
 const get64 = {path, f
 	match bio.getle64(f)
-	| `bio.Ok v:	-> v
+	| `std.Ok v:	-> v
 	| res:	std.fatal("failed to read {}: {}\n", path, res)
 	;;
 }