Parse a S-expression from the given channel. Can read more data than necessary, so don't use this if you need finer-grained control (e.g. to read something else after the S-exp)
type pt = {x:int; y:int };;
let pt_of_sexp e =
Sexp.Traverse.(
field "x" to_int e >>= fun x ->
field "y" to_int e >>= fun y ->
return {x;y}
);;
let sexp_of_pt pt = Sexp.(of_record ["x", of_int pt.x; "y", of_int pt.y]);;
let l = [{x=1;y=1}; {x=2;y=10}];;
let sexp = Sexp.(of_list (List.map sexp_of_pt l));;
Sexp.Traverse.list_all pt_of_sexp sexp;;