ocaml

Loading a file with multiple sexp in OCaml


I want to load a file with multiple sexp and get a list of sexp, and convert the list to a list of some custom type. I know that Core.Sexp.load_sexp_conv_exn filename ty_of_sexp can load a file with a single sexp and convert it to type ty, but I can't find something to do that for files with multiple sexp. Do I have to do that manually myself or are there solutions in the standard library that I haven't found?


Solution

  • Looks like you might want Sexplib.Sexp.load_sexps.

    load_sexps ?buf file reads a list of whitespace separated S-expressions from file using buffer buf for storing intermediate data. Faster than the scan-functions.