123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960openDescmoduleStringMap=Stdcompat.Map.Make(String)type('a,'arity,'b)typed_attribute_kind+=|Attribute_default:('a,'arity,'a)typed_attribute_kindtype('arity,'rec_group,'kinds,'positive,'negative,'direct,'gadt)field=|F:('a,'structure,'arity,'rec_group,'kinds,'positive,'negative,'direct,'gadt)desc*'a->('arity,'rec_group,'kinds,'positive,'negative,'direct,'gadt)fieldletrecmake_fields:typetypesstructures.(types,structures,'arity,'rec_group,'kinds,'positive,'negative,'direct,'gadt)record_structure->('arity,'rec_group,'kinds,'positive,'negative,'direct,'gadt)fieldStringMap.t->types=funstructuresfields->matchstructureswith|RNil->()|RCons{head=Poly_;_}->invalid_arg"make: polymorphic fields unsupported"|RCons{head=Monohead;tail}->lethead=matchStringMap.find_opthead.labelfieldswith|None->beginmatchhead.attributes.typedAttribute_defaultwith|Somedefault->default|None->invalid_arg(Printf.sprintf"make: no value for field '%s'"head.label)end|Some(F(desc,value))->matchConvert.castdeschead.descvaluewith(*
| exception Convert.Incompatible ->
invalid_arg
(Printf.sprintf "make: invalid value type for field '%s'"
head.label);*)|value->valueinhead,make_fieldstailfieldstype('a,'b)record_type_structure=[`RecGroupof[`Nameof[`Recordof'a]]*'b]letmake:typeastructuresnew_rec_group.(a,(structures,new_rec_group)record_type_structure,'arity,'rec_group,'kinds,'positive,'negative,'direct,'gadt)desc->('arity,new_rec_group,'kinds,'positive,'negative,'direct,'gadt)fieldStringMap.t->a=fundescfields->letRecGroup{desc=Name{desc=Record{structure;construct;_};_};_}=descinconstruct(make_fieldsstructurefields)