Got error when serializing Hash_set
Closed this issue · 1 comments
impvd commented
According to the test_hash_set.ml
let%expect_test "sexp" =
let ints = List.init 20 ~f:(fun x -> x * x) in
let int_hash_set = Hash_set.of_list (module Int) ints in
print_s [%sexp (int_hash_set : int Hash_set.t)];
[%expect {| (0 1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361) |}];
let strs = List.init 20 ~f:(fun x -> Int.to_string x) in
let str_hash_set = Hash_set.of_list (module String) strs in
print_s [%sexp (str_hash_set : string Hash_set.t)];
[%expect {| (0 1 10 11 12 13 14 15 16 17 18 19 2 3 4 5 6 7 8 9) |}]
I tried to type the code in utop:
$ utop -require ppx_sexp_conv
# open Core;;
# let s1 = Hash_set.create (module String);;
# Hash_set.add s1 "ok";;
# Hash_set.add s1 "aha";;
# Stdio.print_s [%sexp s1];;
Line 1, characters 16-20:
Error: Uninterpreted extension 'sexp'.
I was wondering how the [%sexp
works in the test file?
bcc32 commented
[%sexp]
is provided by ppx_sexp_value
rather than ppx_sexp_conv
. I suspect it will work if you just pass that to utop.