Combinator library for extracting data for s-exps?

Slightly OT, but if we’re looking at the original problem, then

For this problem, the following assumption seems to be needlessly strong:

Because dune uses sexps for serialisation, and dune itself is written in OCaml (and thus is serialising OCaml values), there’s a good chance that the s-expression should fit into an OCaml type no?

Something like the following should work no?:

type module_spec = {
  name: string;
  impl: string option;
  intf: string option;
  cmt: string option;
  cmti: string option;
} [@@deriving sexp, show]

type executable = {
  names: string list;
  requires: string list;
  modules: module_spec list;
}  [@@sexp.allow_extra_fields] [@@deriving sexp, show]

type library = {
  name: string;
  uid: string;
  local: bool;
  requires: string list;
  source_dir: string;
  include_dirs: string list;
  modules: module_spec list;
}  [@@sexp.allow_extra_fields] [@@deriving sexp, show]

1 Like