Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file dyn.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165moduleArray=Stdlib.ArrayLabelsmoduleList=Stdlib.ListLabelsmoduleString=Stdlib.StringLabelsmoduleBytes=Stdlib.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^"\""]))))letpp_sequencestartstopx~f=letopenPp.Oinmatchxwith|[]->Pp.verbatimstart++Pp.verbatimstop|_->letsep=";"^String.make(String.lengthstart)' 'inPp.hvbox(Pp.concat_mapi~sep:Pp.cutx~f:(funix->Pp.box((ifi=0thenPp.verbatim(start^" ")elsePp.verbatimsep)++fx))++Pp.space++Pp.verbatimstop)letrecpp=letopenPp.Oinfunction|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]))|Listxs->pp_sequence"[""]"xs~f:pp|Arrayxs->pp_sequence"[|""|]"(Array.to_listxs)~f:pp|Setxs->Pp.box~indent:2(Pp.verbatim"set"++Pp.space++pp_sequence"{""}"xs~f:pp)|Mapxs->Pp.box~indent:2(Pp.verbatim"map"++Pp.space++pp_sequence"{""}"xs~f:(fun(k,v)->Pp.box~indent:2(ppk++Pp.space++Pp.char':'++Pp.space++ppv)))|Tuplex->Pp.box(Pp.char'('++Pp.concat_map~sep:(Pp.seq(Pp.char',')Pp.space)x~f:pp++Pp.char')')|Recordfields->pp_sequence"{""}"fields~f:(fun(f,v)->Pp.box~indent:2(Pp.verbatimf++Pp.space++Pp.char'='++Pp.space++ppv))|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()=Unitletcharx=Charxletstringx=Stringxletintx=Intxletfloatx=Floatxletboolx=Boolxletpairfg(x,y)=Tuple[fx;gy]lettriplefgh(x,y,z)=Tuple[fx;gy;hz]letlistfl=List(List.map~fl)letarrayfa=Array(Array.map~fa)letoptionfx=Option(matchxwith|None->None|Somex->Some(fx))letrecordr=Recordrletunknown_=String"<unknown>"letopaque_=String"<opaque>"letconstrsargs=Variant(s,args)endletopaque=String"<opaque>"typedyn=tlethash=Stdlib.Hashtbl.hashletcomparexy=Ordering.of_int(comparexy)