-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Zilin Chen
authored and
Zilin Chen
committed
Jan 12, 2017
1 parent
e75ae71
commit cdcb9f1
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
type WordArray a | ||
|
||
type WordArrayIndex = U32 | ||
|
||
type R a b = <Success a | Error b> | ||
|
||
|
||
wordarray_get: all(a :< DSE). ((WordArray a)!, WordArrayIndex) -> a | ||
|
||
wordarray_get_bounded: all(a :< DSE). ((WordArray a)!, WordArrayIndex) -> R a () | ||
wordarray_get_bounded (arr, idx) = | ||
if idx < wordarray_length[a] (arr) then | ||
Success (wordarray_get[a] (arr, idx)) | ||
else | ||
Error () | ||
|
||
wordarray_length: all(a :< DSE). (WordArray a)! -> U32 | ||
|
||
type Buffer = { | ||
data : WordArray u8 | ||
, bound : U32 | ||
} | ||
|
||
buf_length: Buffer! -> U32 | ||
buf_length buf = wordarray_length (buf.data) |