123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116open!ImportmoduleStable=structmoduleV1=structtypet=Base.Sexp.t=|Atomofstring|Listoftlist[@@derivingbin_io,compare,hash]lett_of_sexp=Sexplib.Sexp.t_of_sexpletsexp_of_t=Sexplib.Sexp.sexp_of_tendendincludeStable.V1include(Base.Sexp:moduletypeofstructincludeBase.Sexpendwithtypet:=t)include(Sexplib.Sexp:moduletypeofstructincludeSexplib.Sexpendwithtypet:=t)moduleO=structtypesexp=Base.Sexp.t=|Atomofstring|ListoftlistendmoduleSexp_maybe=structtypenonrec'at=('a,t*Error.t)Result.t[@@derivingbin_io,compare,hash]letsexp_of_tsexp_of_at=matchtwith|Result.Oka->sexp_of_aa|Result.Error(sexp,err)->List[Atom"sexp_parse_error";sexp;Error.sexp_of_terr];;lett_of_sexpa_of_sexpsexp=matchsexpwith|List[Atom"sexp_parse_error";sexp;_]|sexp->(tryResult.Ok(a_of_sexpsexp)with|exn->Result.Error(sexp,Error.of_exnexn));;endmoduleWith_text=structopenResult.Exporttype'at={value:'a;text:string}[@@derivingbin_io]letsexp_of_t_t=Atomt.textletof_textvalue_of_sexp?(filename="")text=matchOr_error.try_with(fun()->of_string_convtextvalue_of_sexp)with|Ok(`Resultvalue)->Ok{value;text}|Error_aserr->err|Ok(`Error(exn,annotated))->Error(Error.of_exn(Annotated.get_conv_exnannotated~file:filename~exc:exn));;lett_of_sexpa_of_sexpsexp=matchsexpwith|List_->of_sexp_error"With_text.t should be stored as an atom, but instead a list was found."sexp|Atomtext->of_texta_of_sexptext|>Or_error.ok_exn;;lettextt=t.textletvaluet=t.valueletof_valuesexp_of_valuevalue=lettext=sexp_of_valuevalue|>to_string_humin{value;text};;endtype'ano_raise='a[@@derivingbin_io,sexp]letsexp_of_no_raisesexp_of_aa=trysexp_of_aawith|exn->(tryList[Atom"failure building sexp";sexp_of_exnexn]with|_->Atom"could not build sexp for exn raised when building sexp for value");;includeComparable.Extend(Base.Sexp)(Base.Sexp)letof_sexp_allow_extra_fields_recursivelyof_sexpsexp=letr=Sexplib.Conv.record_check_extra_fieldsinletprev=!rinExn.protect~finally:(fun()->r:=prev)~f:(fun()->r:=false;of_sexpsexp);;letquickcheck_generator=Base_quickcheck.Generator.sexpletquickcheck_observer=Base_quickcheck.Observer.sexpletquickcheck_shrinker=Base_quickcheck.Shrinker.sexp