let to_yojson =     let string s = `String s in     let option f o : Yojson.Safe.json = Option.value_map o ~default:`Null ~f in     let data_to_yojson =       function       | PE (r1, r2) ->         `Assoc ["paired-end"`Assoc ["r1", string r1; "r2", string r2]]       | SE f -> `Assoc ["single-end", string f]       | Of_bam (how, sorto, refb, fil) ->         `Assoc ["bam",                 `Assoc ["kind",                         string (match how with                           | `PE -> "paired-end"                           | `SE -> "single-end");                         "sorting",                         (match sorto with                         | None  -> `Null                         | Some `Read_name -> `String "read-name"                         | Some `Coordinate -> `String "coordinate");                         "reference-genome", string refb;                         "path", string fil]]     in     let file_to_yojson (fragment_option, data) =       `Assoc [         "fragment-id", option string fragment_option;         "data", data_to_yojson data;     ] in     let files_to_yojson files = `List (List.map ~f:file_to_yojson files) in     function     | Fastq {fastq_sample_name; files} ->       `Assoc [current_version_tag,               `Assoc ["fastq"`Assoc [                   "sample-name", string fastq_sample_name;                   "fragments", files_to_yojson files;                 ]]]     | Bam bam ->       `Assoc [current_version_tag,               `Assoc ["bam", bam_to_yojson bam]]