diff options
Diffstat (limited to 'test/ocaml/vec_32_64/vec_32_64.sail')
| -rw-r--r-- | test/ocaml/vec_32_64/vec_32_64.sail | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/ocaml/vec_32_64/vec_32_64.sail b/test/ocaml/vec_32_64/vec_32_64.sail new file mode 100644 index 00000000..eb518515 --- /dev/null +++ b/test/ocaml/vec_32_64/vec_32_64.sail @@ -0,0 +1,28 @@ +(* This example is more testing the typechecker flow typing rather +than the ocaml backend, but it does test that recursive functions work +correctly *) + +val get_size : unit -> {|32, 64|} + +function get_size () = 32 + +val only64 = { ocaml: "(fun _ -> ())" } : bits(64) -> unit + +val zeros : forall 'n. atom('n) -> vector('n - 1, 'n, dec, bit) + +function zeros n = + if (n == 1 + 0) then 0b0 else 0b0 @ zeros('n - 1) + +val main : unit -> unit + +function main () = { + let 'length = get_size (); + let xs = zeros(length); + if (length == 32) then { + () + } else { + only64(xs) + }; + print_bits("xs = ", xs); + print_bits("zeros(64) = ", zeros(64)) +}
\ No newline at end of file |
