1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465(*{{{ Copyright (c) 2014 Rudi Grinberg
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
}}}*)openSexplib0.Sexp_convtypet=[`Empty|`Stringofstring|`Stringsofstringlist][@@derivingsexp]letempty=`Emptyletis_empty=function|`Empty|`String""->true|`String_->false|`Stringsxs->(matchList.filter(funs->s<>"")xswith[]->true|_->false)letto_string=function|`Empty->""|`Strings->s|`Stringssl->String.concat""slletto_string_list=function|`Empty->[]|`Strings->[s]|`Stringssl->slletof_strings=`Stringsletof_string_lists=`Stringsslettransfer_encoding=function|`Empty->Transfer.Fixed0L|`Strings->Transfer.Fixed(Int64.of_int(String.lengths))|`Strings_->Transfer.Chunkedletlength=function|`Empty->0L|`Strings->Int64.of_int(String.lengths)|`Stringssl->sl|>List.fold_left(funab->b|>String.length|>Int64.of_int|>Int64.adda)0Lletmapf=function|`Empty->`Empty|`Strings->`String(fs)|`Stringssl->`Strings(List.mapfsl)letto_formt=Uri.query_of_encoded(to_stringt)letof_form?schemef=Uri.encoded_of_query?schemef|>of_string(* TODO: maybe add a functor here that uses IO.S *)