Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file dyn.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180moduleArray=Dune_caml.ArrayLabelsmoduleList=Dune_caml.ListLabelsmoduleString=Dune_caml.StringLabelsmoduleBytes=Dune_caml.Bytestypet=|Opaque|Unit|Intofint|Boolofbool|Stringofstring|Bytesofbytes|Charofchar|Floatoffloat|Optionoftoption|Listoftlist|Arrayoftarray|Tupleoftlist|Recordof(string*t)list|Variantofstring*tlist|Mapof(t*t)list|Setoftlistletunsnocl=matchList.revlwith|last::before_last->Some(List.revbefore_last,last)|[]->Noneletstring_in_ocaml_syntaxstr=letis_space=function|' '->(* don't need to handle tabs because those are already escaped *)true|_->falseinletescape_protect_first_spaces=letfirst_char=ifString.lengths>0&&is_spaces.[0]then"\\"else" "infirst_char^String.escapedsin(* CR-someday aalekseyev: should use the method from
[Dune_lang.prepare_formatter] so that the formatter can fit multiple
lines on one line. *)matchString_split.split~on:'\n'strwith|[]->assertfalse|first::rest->matchunsnocrestwith|None->Pp.verbatim(Printf.sprintf"%S"first)|Some(middle,last)->Pp.vbox(Pp.concat~sep:Pp.newline(List.map~f:Pp.verbatim(("\""^(String.escapedfirst)^"\\n\\")::List.mapmiddle~f:(funs->(escape_protect_first_spaces)^"\\n\\")@[escape_protect_first_spacelast^"\""])))letrecpp=function|Opaque->Pp.verbatim"<opaque>"|Unit->Pp.verbatim"()"|Inti->Pp.verbatim(string_of_inti)|Boolb->Pp.verbatim(string_of_boolb)|Strings->string_in_ocaml_syntaxs|Bytesb->string_in_ocaml_syntax(Bytes.to_stringb)|Charc->Pp.charc|Floatf->Pp.verbatim(string_of_floatf)|OptionNone->pp(Variant("None",[]))|Option(Somex)->pp(Variant("Some",[x]))|Listx->Pp.box(Pp.concat[Pp.char'[';Pp.concat_map~sep:(Pp.seq(Pp.char';')Pp.space)x~f:pp;Pp.char']'])|Arraya->Pp.box(Pp.concat[Pp.verbatim"[|";Pp.concat_map~sep:(Pp.seq(Pp.char';')Pp.space)(Array.to_lista)~f:pp;Pp.verbatim"|]"])|Setxs->Pp.box(Pp.concat[Pp.verbatim"set {";Pp.concat_map~sep:(Pp.seq(Pp.char';')Pp.space)xs~f:pp;Pp.verbatim"}"])|Mapxs->Pp.box(Pp.concat[Pp.verbatim"map {";Pp.concat_map~sep:(Pp.seq(Pp.char';')Pp.space)xs~f:(fun(k,v)->Pp.box(Pp.concat[ppk;Pp.space;Pp.verbatim":";Pp.space;ppv]));Pp.verbatim"}"])|Tuplex->Pp.box(Pp.concat[Pp.char'(';Pp.concat_map~sep:(Pp.seq(Pp.char',')Pp.space)x~f:pp;Pp.char')'])|Recordfields->Pp.vbox~indent:2(Pp.concat[Pp.char'{';Pp.concat_mapfields~sep:(Pp.seq(Pp.char';')Pp.space)~f:(fun(f,v)->Pp.box~indent:2(Pp.concat[Pp.verbatimf;Pp.space;Pp.char'=';Pp.space;ppv]));Pp.char'}'])|Variant(v,[])->Pp.verbatimv|Variant(v,xs)->Pp.hvbox~indent:2(Pp.concat[Pp.verbatimv;Pp.space;Pp.concat_map~sep:(Pp.char',')xs~f:pp])letto_stringt=Format.asprintf"%a"Pp.render_ignore_tags(ppt)moduleEncoder=structtypedyn=ttype'at='a->dynletunit=fun()->Unitletchar=funx->Charxletstring=funx->Stringxletint=funx->Intxletfloat=funx->Floatxletbool=funx->Boolxletpairfg=fun(x,y)->Tuple[fx;gy]lettriplefgh=fun(x,y,z)->Tuple[fx;gy;hz]letlistf=funl->List(List.map~fl)letarrayf=funa->Array(Array.map~fa)letoptionf=funx->Option(matchxwith|None->None|Somex->Some(fx))letrecordr=Recordrletunknown_=String"<unknown>"letopaque_=String"<opaque>"letconstrsargs=Variant(s,args)endletopaque=String"<opaque>"typedyn=tlethash=Dune_caml.Hashtbl.hashletcomparexy=Ordering.of_int(comparexy)