Skip to content

Commit

Permalink
compiler: a file for #29
Browse files Browse the repository at this point in the history
  • Loading branch information
Zilin Chen authored and ajaysusarla committed Nov 28, 2016
1 parent 9988a43 commit 147d30f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions cogent/tests/pass_ticket-e29.cogent
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)

0 comments on commit 147d30f

Please sign in to comment.