summaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/blat.myr4
-rw-r--r--lib/std/dial+plan9.myr26
-rw-r--r--lib/std/dial+posixy.myr26
-rw-r--r--lib/std/dialparse+posixy.myr6
-rw-r--r--lib/std/dir+freebsd.myr2
-rw-r--r--lib/std/dir+linux.myr2
-rw-r--r--lib/std/dir+openbsd.myr2
-rw-r--r--lib/std/dir+osx.myr2
-rw-r--r--lib/std/dir+plan9.myr4
-rw-r--r--lib/std/env+plan9.myr2
-rw-r--r--lib/std/listen+posixy.myr34
-rw-r--r--lib/std/mktemp.myr6
-rw-r--r--lib/std/readall.myr4
-rw-r--r--lib/std/resolve+posixy.myr12
-rw-r--r--lib/std/result.myr2
-rw-r--r--lib/std/slurp.myr6
-rw-r--r--lib/std/spork.myr16
-rw-r--r--lib/std/syswrap+plan9.myr6
-rw-r--r--lib/std/syswrap+posixy.myr2
-rw-r--r--lib/std/try.myr4
-rw-r--r--lib/std/writeall.myr2
21 files changed, 85 insertions, 85 deletions
diff --git a/lib/std/blat.myr b/lib/std/blat.myr
index 803f7ec..c0e2b4b 100644
--- a/lib/std/blat.myr
+++ b/lib/std/blat.myr
@@ -9,7 +9,7 @@ pkg std =
const blat = {path, buf, perm
match openmode(path, Ocreat|Owronly, perm)
| `Ok fd: -> fblat(fd, buf)
- | `Fail e: -> false
+ | `Err e: -> false
;;
}
@@ -20,7 +20,7 @@ const fblat = {fd, buf
count = 0
while true
match write(fd, buf[count:])
- | `Fail e: -> false
+ | `Err e: -> false
| `Ok n:
if n == 0
break
diff --git a/lib/std/dial+plan9.myr b/lib/std/dial+plan9.myr
index 75da35b..65ef984 100644
--- a/lib/std/dial+plan9.myr
+++ b/lib/std/dial+plan9.myr
@@ -29,7 +29,7 @@ const dial = {str
match csdial("/net", proto, rem)
| `Ok fd: -> `Ok fd
- | `Fail m:
+ | `Err m:
-> csdial("/net.alt", proto, rem)
;;
}
@@ -42,15 +42,15 @@ const csdial = {netdir, proto, rem
/* Try using the connection server */
dir = fmt("{}/cs", netdir)
match open(dir, Ordwr)
- | `Fail e:
+ | `Err e:
clone = fmt("{}/{}/clone", netdir, proto)
match call(clone, rem, netdir)
| `Ok fd:
std.slfree(clone)
-> `Ok fd
- | `Fail err:
+ | `Err err:
std.slfree(clone)
- -> `Fail "unable to dial without cs"
+ -> `Err "unable to dial without cs"
;;
| `Ok fd:
csfd = fd
@@ -59,9 +59,9 @@ const csdial = {netdir, proto, rem
csaddr = fmt("{}!{}", proto, rem)
match write(csfd, csaddr)
- | `Fail m:
+ | `Err m:
close(csfd)
- -> `Fail "couldn't blah cs"
+ -> `Err "couldn't blah cs"
| `Ok _:
/* nothing */
;;
@@ -71,7 +71,7 @@ const csdial = {netdir, proto, rem
while true
match read(csfd, buf[:])
| `std.Ok _:
- | `std.Fail e:
+ | `std.Err e:
break
;;
@@ -84,13 +84,13 @@ const csdial = {netdir, proto, rem
match call(clone, addr, netdir)
| `Ok fd: break
- | `Fail _: /* nothing */
+ | `Err _: /* nothing */
;;
;;
close(csfd)
if ret < 0
- -> `Fail "unable to dial"
+ -> `Err "unable to dial"
;;
-> `Ok ret
}
@@ -102,16 +102,16 @@ const call : (a : byte[:], b : byte[:], c : byte[:] -> result(fd, byte[:])) = {c
var cfd, datafd
var c, n
- datafd = `Fail "didn't even try to open shit"
+ datafd = `Err "didn't even try to open shit"
c = nsclonestr(clone, netdir)
match open(c, Ordwr)
- | `Fail e: goto cleanup
+ | `Err e: goto cleanup
| `Ok fd: cfd = fd
;;
match read(cfd, namebuf[:])
| `Ok fd: /* nothing */
- | `Fail m: goto cleanup
+ | `Err m: goto cleanup
;;
fput(cfd, "connect {}", addr)
name = strstrip(namebuf[:n])
@@ -122,7 +122,7 @@ const call : (a : byte[:], b : byte[:], c : byte[:] -> result(fd, byte[:])) = {c
dpath = bfmt(databuf[:], "{}/{}/data", base, name)
match open(dpath, Ordwr)
| `Ok fd: datafd = `Ok fd
- | `Fail m: datafd = `Fail "could not open data"
+ | `Err m: datafd = `Err "could not open data"
;;
:cleanup
close(cfd)
diff --git a/lib/std/dial+posixy.myr b/lib/std/dial+posixy.myr
index 2ee6345..07e8e6e 100644
--- a/lib/std/dial+posixy.myr
+++ b/lib/std/dial+posixy.myr
@@ -33,8 +33,8 @@ const dial = {ds
| `Some ("tcp", str): -> dialsock(sys.Sockstream, str)
| `Some ("udp", str): -> dialsock(sys.Sockdgram, str)
| `Some ("unix", u): -> dialunix(u)
- | `Some (proto, str): -> `Fail "unknown protocol"
- | `None: -> `Fail "missing protocol"
+ | `Some (proto, str): -> `Err "unknown protocol"
+ | `None: -> `Err "missing protocol"
;;
}
@@ -47,15 +47,15 @@ const dialsock = {proto, str
var err
match nameseg(str)
- | `None: -> `Fail "required host!port for ip dial"
- | `Some ("", _): -> `Fail "empty host"
- | `Some (_, ""): -> `Fail "empty port"
+ | `None: -> `Err "required host!port for ip dial"
+ | `Some ("", _): -> `Err "empty host"
+ | `Some (_, ""): -> `Err "empty port"
| `Some segs: (hoststr, portstr) = segs
;;
match parseport(portstr)
| `Some p: port = p
- | `None: -> `Fail("invalid port")
+ | `None: -> `Err("invalid port")
;;
match getaddr(hoststr)
@@ -67,18 +67,18 @@ const dialsock = {proto, str
sa6=[.fam=sys.Afinet6, .addr=bits, .port=hosttonet(port)]
sa = (&sa6 : sys.sockaddr#)
sz = sizeof(sys.sockaddr_in6)
- | `Fail m:
- -> `Fail m
+ | `Err m:
+ -> `Err m
;;
sock = sys.socket(sa.fam, proto, 0)
if sock < 0
- -> `Fail "failed to create socket"
+ -> `Err "failed to create socket"
;;
err = sys.connect(sock, sa, sz)
if err < 0
sys.close(sock)
- -> `Fail "Failed to bind socket"
+ -> `Err "Failed to bind socket"
;;
-> `Ok (sock : fd)
@@ -90,16 +90,16 @@ const dialunix = {path
sa = [.fam = sys.Afunix]
if path.len >= sa.path.len
- -> `Fail "path too long"
+ -> `Err "path too long"
;;
sock = sys.socket(sys.Afunix, sys.Sockstream, 0)
if sock < 0
- -> `Fail "failed to create socket"
+ -> `Err "failed to create socket"
;;
slcp(sa.path[:path.len], path)
if sys.connect(sock, (&sa : sys.sockaddr#), sizeof(sys.sockaddr_un)) < 0
- -> `Fail "failed to bind address"
+ -> `Err "failed to bind address"
;;
-> `Ok (sock : fd)
}
diff --git a/lib/std/dialparse+posixy.myr b/lib/std/dialparse+posixy.myr
index 8d544c6..2d0a695 100644
--- a/lib/std/dialparse+posixy.myr
+++ b/lib/std/dialparse+posixy.myr
@@ -49,10 +49,10 @@ const getaddr = {addr
slfree(hi)
else
slfree(hi)
- -> `Fail "no hosts resolved for addr"
+ -> `Err "no hosts resolved for addr"
;;
- | `Fail m:
- -> `Fail "could not get host info"
+ | `Err m:
+ -> `Err "could not get host info"
;;
;;
-> `Ok ip
diff --git a/lib/std/dir+freebsd.myr b/lib/std/dir+freebsd.myr
index 1177f2b..8d1c13f 100644
--- a/lib/std/dir+freebsd.myr
+++ b/lib/std/dir+freebsd.myr
@@ -28,7 +28,7 @@ const diropen = {p
fd = sys.open(p, sys.Ordonly | sys.Odir)
if fd < 0
- -> `Fail "couldn't open directory"
+ -> `Err "couldn't open directory"
;;
dir = zalloc()
dir.fd = fd
diff --git a/lib/std/dir+linux.myr b/lib/std/dir+linux.myr
index d3aed77..1ce2513 100644
--- a/lib/std/dir+linux.myr
+++ b/lib/std/dir+linux.myr
@@ -30,7 +30,7 @@ const diropen = {p
fd = sys.open(p, sys.Ordonly | sys.Odir)
if fd < 0
- -> `Fail "couldn't open directory"
+ -> `Err "couldn't open directory"
;;
dir = zalloc()
dir.fd = fd
diff --git a/lib/std/dir+openbsd.myr b/lib/std/dir+openbsd.myr
index c77d01d..274175d 100644
--- a/lib/std/dir+openbsd.myr
+++ b/lib/std/dir+openbsd.myr
@@ -28,7 +28,7 @@ const diropen = {p
fd = sys.open(p, sys.Ordonly | sys.Odir)
if fd < 0
- -> `Fail "couldn't open directory"
+ -> `Err "couldn't open directory"
;;
dir = zalloc()
dir.fd = fd
diff --git a/lib/std/dir+osx.myr b/lib/std/dir+osx.myr
index cc3e1a3..9992787 100644
--- a/lib/std/dir+osx.myr
+++ b/lib/std/dir+osx.myr
@@ -28,7 +28,7 @@ const diropen = {p
fd = sys.open(p, sys.Ordonly | sys.Odir)
if fd < 0
- -> `Fail "couldn't open directory"
+ -> `Err "couldn't open directory"
;;
dir = zalloc()
dir.fd = fd
diff --git a/lib/std/dir+plan9.myr b/lib/std/dir+plan9.myr
index 03e77ed..e363662 100644
--- a/lib/std/dir+plan9.myr
+++ b/lib/std/dir+plan9.myr
@@ -28,7 +28,7 @@ const diropen = {p
match open(p, Ordonly)
| `Ok f: fd = f
- | `Fail e: -> `Fail "couldn't open directory"
+ | `Err e: -> `Err "couldn't open directory"
;;
dir = zalloc()
@@ -45,7 +45,7 @@ const dirread = {d
match read(d.fd, d.buf[:])
| `Ok 0:
-> `None
- | `Fail e:
+ | `Err e:
-> `None
| `Ok len:
d.len = (len : int64)
diff --git a/lib/std/env+plan9.myr b/lib/std/env+plan9.myr
index 77763de..bc9bd3d 100644
--- a/lib/std/env+plan9.myr
+++ b/lib/std/env+plan9.myr
@@ -43,7 +43,7 @@ const getenv = {name
| `None:
s = fmt("/env/{}", name)
match std.slurp(s)
- | `Fail m:
+ | `Err m:
ret = `None
| `Ok data:
data = cstrconv(data)
diff --git a/lib/std/listen+posixy.myr b/lib/std/listen+posixy.myr
index 22ff497..d8a5708 100644
--- a/lib/std/listen+posixy.myr
+++ b/lib/std/listen+posixy.myr
@@ -26,8 +26,8 @@ const announce = {ds
| `Some ("tcp", str): -> announcesock(sys.Sockstream, str)
| `Some ("udp", str): -> announcesock(sys.Sockdgram, str)
| `Some ("unix", str): -> announceunix(str)
- | `Some (proto, str): -> `Fail "unknown protocol"
- | `None: -> `Fail "missing protocol"
+ | `Some (proto, str): -> `Err "unknown protocol"
+ | `None: -> `Err "missing protocol"
;;
}
@@ -40,15 +40,15 @@ const announcesock = {proto, str
var yes
match nameseg(str)
- | `None: -> `Fail "required addr!port for ip listen"
- | `Some ("", _): -> `Fail "empty host"
- | `Some (_, ""): -> `Fail "empty port"
+ | `None: -> `Err "required addr!port for ip listen"
+ | `Some ("", _): -> `Err "empty host"
+ | `Some (_, ""): -> `Err "empty port"
| `Some segs: (hoststr, portstr) = segs
;;
match parseport(portstr)
| `Some p: port = p
- | `None: -> `Fail("invalid port")
+ | `None: -> `Err("invalid port")
;;
if std.sleq(hoststr, "*")
@@ -65,20 +65,20 @@ const announcesock = {proto, str
sa6=[.fam=sys.Afinet6, .addr=bits, .port=hosttonet(port)]
sa = (&sa6 : sys.sockaddr#)
sz = sizeof(sys.sockaddr_in6)
- | `Fail m:
- -> `Fail m
+ | `Err m:
+ -> `Err m
;;
;;
sock = sys.socket(sa.fam, proto, 0)
if sock < 0
- -> `Fail "failed to create socket"
+ -> `Err "failed to create socket"
;;
yes = 1
if sys.setsockopt(sock, sys.Solsock, sys.Soreuseaddr, (&yes : void#), sizeof(int)) < 0
- -> `Fail "failed to set sock opts"
+ -> `Err "failed to set sock opts"
;;
if sys.bind(sock, sa, sz) < 0
- -> `Fail "failed to bind socket"
+ -> `Err "failed to bind socket"
;;
-> `Ok (sock : fd)
}
@@ -90,21 +90,21 @@ const announceunix = {path
sa = [.fam = sys.Afunix]
if path.len >= sa.path.len
- -> `Fail "path too long"
+ -> `Err "path too long"
;;
slcp(sa.path[:path.len], path)
sock = sys.socket(sys.Afunix, sys.Sockstream, 0)
if sock < 0
- -> `Fail "failed to create socket"
+ -> `Err "failed to create socket"
;;
yes = 1
if sys.setsockopt(sock, sys.Solsock, sys.Soreuseaddr, (&yes : void#), sizeof(int)) < 0
- -> `Fail "failed to set sock opts"
+ -> `Err "failed to set sock opts"
;;
sys.unlink(path)
if sys.bind(sock, (&sa : sys.sockaddr#), sizeof(sys.sockaddr_un)) < 0
- -> `Fail "failed to bind address"
+ -> `Err "failed to bind address"
;;
-> `Ok (sock : fd)
@@ -112,7 +112,7 @@ const announceunix = {path
const listen = {sock : std.fd -> result(fd, byte[:])
if sys.listen((sock : sys.fd), 10) < 0
- -> `Fail "unable to listen on socket"
+ -> `Err "unable to listen on socket"
;;
-> `Ok (sys.dup((sock : sys.fd)) : fd)
}
@@ -124,7 +124,7 @@ const accept = {lfd
fd = sys.accept((lfd : sys.fd), (0 : sys.sockaddr#), (0 : sys.size#))
if fd < 0
- -> `Fail "unable to accept socket"
+ -> `Err "unable to accept socket"
;;
-> `Ok (fd : fd)
}
diff --git a/lib/std/mktemp.myr b/lib/std/mktemp.myr
index 13de4ea..c5f06c8 100644
--- a/lib/std/mktemp.myr
+++ b/lib/std/mktemp.myr
@@ -38,17 +38,17 @@ const mktempat = {tmpdir, base, opt, mode
for var i = 0; i < Retries; i++
path = randpath(tmpdir, base)
match std.openmode(path, opt | Ocreat, mode)
- | `Fail e:
+ | `Err e:
if e != Eexist
std.slfree(path)
- -> `Fail e
+ -> `Err e
;;
| `Ok fd:
-> `Ok (fd, path)
;;
std.slfree(path)
;;
- -> `Fail Eexist
+ -> `Err Eexist
}
const mktemppath = {base
diff --git a/lib/std/readall.myr b/lib/std/readall.myr
index 33fbc0c..68c930e 100644
--- a/lib/std/readall.myr
+++ b/lib/std/readall.myr
@@ -18,8 +18,8 @@ const readall = {fd, dst
break
| `Ok n:
dst = dst[n:]
- | `Fail e:
- -> `Fail e
+ | `Err e:
+ -> `Err e
;;
;;
-> `Ok sz - dst.len
diff --git a/lib/std/resolve+posixy.myr b/lib/std/resolve+posixy.myr
index c4d6c46..b49a20d 100644
--- a/lib/std/resolve+posixy.myr
+++ b/lib/std/resolve+posixy.myr
@@ -102,7 +102,7 @@ const loadhosts = {
match slurp(Hostfile)
| `Ok d: h = d
- | `Fail m: -> void
+ | `Err m: -> void
;;
lines = strsplit(h, "\n")
@@ -170,7 +170,7 @@ const loadresolv = {
lock(netlck)
match slurp(Resolvfile)
| `Ok d: h = d
- | `Fail m: -> void
+ | `Err m: -> void
;;
lines = strsplit(h, "\n")
@@ -228,7 +228,7 @@ const dnsresolve = {host, rt
var nsrv, r
if !valid(host)
- -> `Fail (`Badhost)
+ -> `Err (`Badhost)
;;
lock(netlck)
for ns in nameservers
@@ -241,7 +241,7 @@ const dnsresolve = {host, rt
;;
;;
unlock(netlck)
- -> `Fail (`Badsrv)
+ -> `Err (`Badsrv)
}
const dnsconnect = {ns
@@ -318,7 +318,7 @@ const rquery = {srv, id
n = sys.read(srv, pktbuf[:])
if n < 0
- -> `Fail `Badconn
+ -> `Err `Badconn
;;
pkt = pktbuf[:n]
-> hosts(pkt, id)
@@ -333,7 +333,7 @@ const hosts = {pkt, id : uint16
/* parse header */
(v, off) = unpack16(pkt, off) /* id */
if v != id
- -> `Fail `Badresp
+ -> `Err `Badresp
;;
(v, off) = unpack16(pkt, off) /* flags */
(q, off) = unpack16(pkt, off) /* qdcount */
diff --git a/lib/std/result.myr b/lib/std/result.myr
index e98078a..2afdc54 100644
--- a/lib/std/result.myr
+++ b/lib/std/result.myr
@@ -1,7 +1,7 @@
pkg std =
type result(@a, @b) = union
`Ok @a
- `Fail @b
+ `Err @b
;;
;;
diff --git a/lib/std/slurp.myr b/lib/std/slurp.myr
index c0e417c..a966e4a 100644
--- a/lib/std/slurp.myr
+++ b/lib/std/slurp.myr
@@ -16,7 +16,7 @@ const Bufstart = 4096
const slurp = {path
var sl
match open(path, Ordonly)
- | `Fail e: -> `Fail e
+ | `Err e: -> `Err e
| `Ok fd:
sl = fslurp(fd)
close(fd)
@@ -41,9 +41,9 @@ const fslurp = {fd
bufsz *= 2
slgrow(&buf, bufsz)
;;
- | `Fail e:
+ | `Err e:
slfree(buf)
- -> `Fail e
+ -> `Err e
;;
;;
die("unreachable")
diff --git a/lib/std/spork.myr b/lib/std/spork.myr
index d06627c..c149dad 100644
--- a/lib/std/spork.myr
+++ b/lib/std/spork.myr
@@ -17,11 +17,11 @@ const spork = {cmd
/* open up pipes */
err = pipe(&infds)
if err != Enone
- -> `Fail err
+ -> `Err err
;;
err = pipe(&outfds)
if err != Enone
- -> `Fail err
+ -> `Err err
;;
match sporkfd(cmd, infds[0], outfds[1])
@@ -30,8 +30,8 @@ const spork = {cmd
close(infds[0]);
close(outfds[1]);
-> `Ok (pid, infds[1], outfds[0])
- | `Fail m:
- -> `Fail m
+ | `Err m:
+ -> `Err m
;;
}
@@ -41,23 +41,23 @@ const sporkfd = {cmd, infd, outfd
pid = fork()
/* error */
if pid < 0
- -> `Fail (pid : errno)
+ -> `Err (pid : errno)
/* child */
elif pid == 0
/* stdin/stdout for our communication. */
match dup2(infd, 0)
| `Ok _: /* nothing */
- | `Fail e: -> `Fail e
+ | `Err e: -> `Err e
;;
match dup2(outfd, 1)
| `Ok _: /* nothing */
- | `Fail e: -> `Fail e
+ | `Err e: -> `Err e
;;
close(infd)
close(outfd)
err = execvp(cmd[0], cmd)
if err != Enone
- -> `Fail err
+ -> `Err err
;;
/* if fork succeeds, we never return */
die("unreachable")
diff --git a/lib/std/syswrap+plan9.myr b/lib/std/syswrap+plan9.myr
index bbabf22..54d9091 100644
--- a/lib/std/syswrap+plan9.myr
+++ b/lib/std/syswrap+plan9.myr
@@ -120,7 +120,7 @@ const fmtime = {path
var buf : byte[Stringsoff + 512] /* enough space for some strings */
if sys.stat(path, buf[:]) < Stringsoff
- -> `Fail Emisc
+ -> `Err Emisc
;;
-> `Ok (getle32(buf[Mtimeoff:Mtimeoff + 8]) : time)
}
@@ -129,7 +129,7 @@ const fsize = {path
var buf : byte[Stringsoff + 512] /* enough space for some strings */
if sys.stat(path, buf[:]) < Stringsoff
- -> `Fail Emisc
+ -> `Err Emisc
;;
-> `Ok (getle64(buf[Lengthoff:Lengthoff + 8]) : off)
}
@@ -246,7 +246,7 @@ const statsz = {buf
generic check = {e : @a::(integral, numeric) -> result(@b, errno)
if e < 0
- -> `Fail lasterr()
+ -> `Err lasterr()
else
-> `Ok (e : @b)
;;
diff --git a/lib/std/syswrap+posixy.myr b/lib/std/syswrap+posixy.myr
index a707a12..2e8474d 100644
--- a/lib/std/syswrap+posixy.myr
+++ b/lib/std/syswrap+posixy.myr
@@ -175,7 +175,7 @@ const fsize = {path
generic check = {e : @a::(integral, numeric) -> result(@b, errno)
if e < 0
- -> `Fail (e : errno)
+ -> `Err (e : errno)
else
-> `Ok (e : @b)
;;
diff --git a/lib/std/try.myr b/lib/std/try.myr
index 4fdda95..ade5a19 100644
--- a/lib/std/try.myr
+++ b/lib/std/try.myr
@@ -12,14 +12,14 @@ pkg std =
generic try = {v
match v
| `Ok x: -> x
- | `Fail m: fatal("error: {}\n", m)
+ | `Err m: fatal("error: {}\n", m)
;;
}
generic tryv = {v, d
match v
| `Ok x: -> x
- | `Fail m: -> d
+ | `Err m: -> d
;;
}
diff --git a/lib/std/writeall.myr b/lib/std/writeall.myr
index 9e5ea09..3559c96 100644
--- a/lib/std/writeall.myr
+++ b/lib/std/writeall.myr
@@ -16,7 +16,7 @@ const writeall = {fd, src
match std.write(fd, src)
| `Ok n:
src = src[n:]
- | `Fail e:
+ | `Err e:
-> (sz - src.len, `Some e)
;;
;;