123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108(* Copyright (C) 2024 Petter A. Urkedal <paurkedal@gmail.com>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version, with the LGPL-3.0 Linking Exception.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* and the LGPL-3.0 Linking Exception along with this library. If not, see
* <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively.
*)openShimstype'at=|Bool:boolt|Int:intt|Int16:intt|Int32:int32t|Int64:int64t|Float:floatt|String:stringt|Octets:stringt|Pdate:Ptime.tt|Ptime:Ptime.tt|Ptime_span:Ptime.spant|Enum:string->stringtletunify:typeab.at->bt->(a,b)Type.eqoption=funft1ft2->(matchft1,ft2with|Bool,Bool->SomeEqual|Bool,_|_,Bool->None|Int,Int->SomeEqual|Int,_|_,Int->None|Int16,Int16->SomeEqual|Int16,_|_,Int16->None|Int32,Int32->SomeEqual|Int32,_|_,Int32->None|Int64,Int64->SomeEqual|Int64,_|_,Int64->None|Float,Float->SomeEqual|Float,_|_,Float->None|String,String->SomeEqual|String,_|_,String->None|Octets,Octets->SomeEqual|Octets,_|_,Octets->None|Pdate,Pdate->SomeEqual|Pdate,_|_,Pdate->None|Ptime,Ptime->SomeEqual|Ptime,_|_,Ptime->None|Ptime_span,Ptime_span->SomeEqual|Ptime_span,_|_,Ptime_span->None|Enumname1,Enumname2whenname1=name2->SomeEqual|Enum_,Enum_->None)letequal_value:typea.at->a->a->bool=function|Bool->Bool.equal|Int->Int.equal|Int16->Int.equal|Int32->Int32.equal|Int64->Int64.equal|Float->Float.equal|String->String.equal|Octets->String.equal|Pdate->Ptime.equal|Ptime->Ptime.equal|Ptime_span->Ptime.Span.equal|Enum_->String.equalletto_string:typea.at->string=function|Bool->"bool"|Int->"int"|Int16->"int16"|Int32->"int32"|Int64->"int64"|Float->"float"|String->"string"|Octets->"octets"|Pdate->"pdate"|Ptime->"ptime"|Ptime_span->"ptime_span"|Enumname->nameletppppfft=Format.pp_print_stringppf(to_stringft)letpp_ptime=Ptime.pp_rfc3339~tz_offset_s:0~space:false()letpp_value:typea._->at*a->unit=funppf->function|Bool,x->Format.pp_print_boolppfx|Int,x->Format.pp_print_intppfx|Int16,x->Format.pp_print_intppfx|Int32,x->Format.fprintfppf"%ldl"x|Int64,x->Format.fprintfppf"%LdL"x|Float,x->Format.fprintfppf"%F"x|String,x->Format.fprintfppf"%S"x|Octets,x->Format.fprintfppf"%S"x|Pdate,x->lety,m,d=Ptime.to_datexinFormat.fprintfppf"%d-%02d-%02d"ymd|Ptime,x->pp_ptimeppfx|Ptime_span,x->Ptime.Span.ppppfx|Enum_,x->Format.pp_print_stringppfx