123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126includeErrormoduleDeserializer=DeserializermoduleError=ErrormoduleImpls=ImplsmoduleReader=ReadermoduleUnimplemented=UnimplementedmoduleVisitor=VisitormoduleSequence_access=Sequence_access(** Access modules *)moduleVariant_access=Variant_accessmoduleMap_access=Map_accessmoduletypeBase=Intf.Deserializer_base_intfmoduletypeDeserializer=Intf.Deserializer_intfmoduletypeFactory=sigtypestatevalmake:state->stateDeserializer.tendmoduleMake(B:Base):Factorywithtypestate=B.state=structtypestate=B.stateletmakestate=letmoduleD=structincludeBletstate=stateendin(moduleD:Deserializerwithtypestate=B.state)end(** boilerplace below is because we don't have modular implicits yet.
it threads the two modules manually, and makes sure the all the types are
escaping correctly.
*)letdeserialize_unit:typevaluestate.stateDeserializer.t->valueVisitor.t->(value,'errorde_error)result=fun(moduleDe)(moduleV)->matchDe.deserialize_unitDe.state(moduleDe)(moduleV)with|exceptione->Error.unexpected_exceptione|res->resletdeserialize_string:typevaluestate.stateDeserializer.t->valueVisitor.t->(value,'errorde_error)result=fun(moduleDe)(moduleV)->matchDe.deserialize_stringDe.state(moduleDe)(moduleV)with|exceptione->Error.unexpected_exceptione|res->resletdeserialize_int:typevaluestate.stateDeserializer.t->valueVisitor.t->(value,'errorde_error)result=fun(moduleDe)(moduleV)->matchDe.deserialize_intDe.state(moduleDe)(moduleV)with|exceptione->Error.unexpected_exceptione|res->resletdeserialize_bool:typevaluestate.stateDeserializer.t->valueVisitor.t->(value,'errorde_error)result=fun(moduleDe)(moduleV)->matchDe.deserialize_boolDe.state(moduleDe)(moduleV)with|exceptione->Error.unexpected_exceptione|res->resletdeserialize_identifier:typevaluestate.stateDeserializer.t->valueVisitor.t->(value,'errorde_error)result=fun(moduleDe)(moduleV)->matchDe.deserialize_identifierDe.state(moduleDe)(moduleV)with|exceptione->Error.unexpected_exceptione|res->resletdeserialize_record:typevaluefieldstate.stateDeserializer.t->(value,field)Visitor.with_tag->fieldVisitor.t->name:string->fields:stringlist->(value,'errorde_error)result=fun(moduleDe)(moduleValue)(moduleField)~name~fields->matchDe.deserialize_recordDe.state(moduleDe)(moduleValue)(moduleField)~name~fieldswith|exceptione->Error.unexpected_exceptione|res->resletdeserialize_seq:typevaluestate.stateDeserializer.t->valueVisitor.t->(value,'errorde_error)result=fun(moduleDe)(moduleV)->matchDe.deserialize_seqDe.state(moduleDe)(moduleV)with|exceptione->Error.unexpected_exceptione|res->resletdeserialize_variant:typevaluetagstate.stateDeserializer.t->(value,tag)Visitor.with_tag->tagVisitor.t->name:string->variants:stringlist->(value,'errorde_error)result=fun(moduleDe)(moduleValue)(moduleVariant)~name~variants->matchDe.deserialize_variantDe.state(moduleDe)(moduleValue)(moduleVariant)~name~variantswith|exceptione->Error.unexpected_exceptione|res->res