summaryrefslogtreecommitdiff
path: root/lib/bio
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-06-25 23:51:13 -0700
committerOri Bernstein <ori@eigenstate.org>2017-06-25 23:51:13 -0700
commita54d7deb4b5cdc397f1e5cf3957edc0b91f5f880 (patch)
tree40be837d1c39b2ff4ba38e80bf1299e324f189b2 /lib/bio
parentd5ade40b51092a405c0ee44b63a461409de20371 (diff)
downloadmc-a54d7deb4b5cdc397f1e5cf3957edc0b91f5f880.tar.gz
Fix some actual type bugs.
Strictness fixes issues. Oops.
Diffstat (limited to 'lib/bio')
-rw-r--r--lib/bio/bio.myr4
-rw-r--r--lib/bio/mem.myr8
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/bio/bio.myr b/lib/bio/bio.myr
index aaae0e0..be82867 100644
--- a/lib/bio/bio.myr
+++ b/lib/bio/bio.myr
@@ -13,7 +13,7 @@ pkg bio =
read : (buf : byte[:] -> std.result(std.size, std.errno))
write : (buf : byte[:] -> std.result(std.size, std.errno))
- seek : (idx : std.off -> std.result(std.size, std.errno))
+ seek : (idx : std.off -> std.result(std.off, std.errno))
close : (-> void)
/* read buffer */
@@ -29,7 +29,7 @@ pkg bio =
type vtab = struct
read : (buf : byte[:] -> std.result(std.size, std.errno))
write : (buf : byte[:] -> std.result(std.size, std.errno))
- seek : (idx : std.off -> std.result(std.size, std.errno))
+ seek : (idx : std.off -> std.result(std.off, std.errno))
close : (-> void)
;;
diff --git a/lib/bio/mem.myr b/lib/bio/mem.myr
index dcafc82..bf89912 100644
--- a/lib/bio/mem.myr
+++ b/lib/bio/mem.myr
@@ -21,7 +21,7 @@ const mkmem = {buf
-> mk(Rd, [
.read = {buf; -> memread(mem, buf)},
.write = {buf; -> memwrite(mem, buf)},
- .seek = {off; mem.off = std.clamp(off, 0, mem.buf.len); -> `std.Ok mem.off},
+ .seek = {off; -> memseek(mem, off)},
.close = {; std.free(mem)},
])
}
@@ -43,3 +43,9 @@ const memwrite = {mem, src
mem.off += n
-> `std.Ok n
}
+
+const memseek = {mem, off : std.off
+ off = std.clamp(off, 0, mem.buf.len)
+ mem.off = (off : std.size)
+ -> `std.Ok off
+}