12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455(** Simple library for concatenating immutable strings efficiently *)open!CoremoduletypeUnderlying=sigtypet=|StringofString.t|BigstringofBigstring.t|CharofcharendmoduletypeString_monoid=sigtypet(** Primitive, constant-time operations *)valempty:tvalnl:tvalplus:t->t->tvallength:t->int(** Linear in the number of elements. *)valconcat:?sep:t->tlist->t(** Linear in the number of elements in the list. *)valconcat_string:?sep:string->stringlist->t(*_ t_of_* is O(1), *_of_t is O(N), N being the length *)includeStringable.Swithtypet:=tvalof_bigstring:Bigstring.t->tvalto_bigstring:t->Bigstring.tvalof_char:char->t(*_
For the library to fulfill it's purpose of minimal overhead
string concatenation, the output functions must be tightly
coupled with the low-level representation.
Any new output channel should be implemented as new methods
of the library itself.
*)valoutput_bigbuffer:t->Bigbuffer.t->unitmoduleUnderlying:Underlyingvalfold:t->init:'accum->f:('accum->Underlying.t->'accum)->'accumvaliter:t->f:(Underlying.t->unit)->unitvalis_suffix:t->suffix:string->boolvalis_prefix:t->prefix:string->boolvalis_substring:t->substring:string->boolvalis_string:t->string:string->boolend