12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367(* This file was automatically generated, do not edit.*)(* Edit file v8.in.ml instead. *)# 1 "v8.in.ml"moduletypeT=sigmoduleCamlinternalFormatBasics:moduletypeofstructincludeTezos_protocol_environment_sigs_internals.CamlinternalFormatBasicsendmodulePervasives:sig# 1 "v8/pervasives.mli"(**************************************************************************)(* *)(* OCaml *)(* *)(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)(* *)(* Copyright 1996 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the GNU Lesser General Public License version 2.1, with the *)(* special exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)(** The OCaml Standard library.
This module is automatically opened at the beginning of each
compilation. All components of this module can therefore be
referred by their short name, without prefixing them by [Stdlib].
It particular, it provides the basic operations over the built-in
types (numbers, booleans, byte sequences, strings, exceptions,
references, lists, arrays, input-output channels, ...) and the
{{!modules}standard library modules}.
*)(** {1 Exceptions} *)externalraise:exn->'a="%raise"(** Raise the given exception value *)externalraise_notrace:exn->'a="%raise_notrace"(** A faster version [raise] which does not record the backtrace.
@since 4.02.0
*)valinvalid_arg:string->'a(** Raise exception [Invalid_argument] with the given string. *)valfailwith:string->'a(** Raise exception [Failure] with the given string. *)exceptionExit(** The [Exit] exception is not raised by any library function. It is
provided for use in your programs. *)(** {1 Boolean operations} *)externalnot:bool->bool="%boolnot"(** The boolean negation. *)external(&&):bool->bool->bool="%sequand"(** The boolean 'and'. Evaluation is sequential, left-to-right:
in [e1 && e2], [e1] is evaluated first, and if it returns [false],
[e2] is not evaluated at all.
Right-associative operator, see {!Ocaml_operators} for more information.
*)external(||):bool->bool->bool="%sequor"(** The boolean 'or'. Evaluation is sequential, left-to-right:
in [e1 || e2], [e1] is evaluated first, and if it returns [true],
[e2] is not evaluated at all.
Right-associative operator, see {!Ocaml_operators} for more information.
*)(** {1 Debugging} *)external__LOC__:string="%loc_LOC"(** [__LOC__] returns the location at which this expression appears in
the file currently being parsed by the compiler, with the standard
error format of OCaml: "File %S, line %d, characters %d-%d".
@since 4.02.0
*)external__FILE__:string="%loc_FILE"(** [__FILE__] returns the name of the file currently being
parsed by the compiler.
@since 4.02.0
*)external__LINE__:int="%loc_LINE"(** [__LINE__] returns the line number at which this expression
appears in the file currently being parsed by the compiler.
@since 4.02.0
*)external__MODULE__:string="%loc_MODULE"(** [__MODULE__] returns the module name of the file being
parsed by the compiler.
@since 4.02.0
*)external__POS__:string*int*int*int="%loc_POS"(** [__POS__] returns a tuple [(file,lnum,cnum,enum)], corresponding
to the location at which this expression appears in the file
currently being parsed by the compiler. [file] is the current
filename, [lnum] the line number, [cnum] the character position in
the line and [enum] the last character position in the line.
@since 4.02.0
*)external__LOC_OF__:'a->string*'a="%loc_LOC"(** [__LOC_OF__ expr] returns a pair [(loc, expr)] where [loc] is the
location of [expr] in the file currently being parsed by the
compiler, with the standard error format of OCaml: "File %S, line
%d, characters %d-%d".
@since 4.02.0
*)external__LINE_OF__:'a->int*'a="%loc_LINE"(** [__LINE_OF__ expr] returns a pair [(line, expr)], where [line] is the
line number at which the expression [expr] appears in the file
currently being parsed by the compiler.
@since 4.02.0
*)external__POS_OF__:'a->(string*int*int*int)*'a="%loc_POS"(** [__POS_OF__ expr] returns a pair [(loc,expr)], where [loc] is a
tuple [(file,lnum,cnum,enum)] corresponding to the location at
which the expression [expr] appears in the file currently being
parsed by the compiler. [file] is the current filename, [lnum] the
line number, [cnum] the character position in the line and [enum]
the last character position in the line.
@since 4.02.0
*)(** {1 Composition operators} *)external(|>):'a->('a->'b)->'b="%revapply"(** Reverse-application operator: [x |> f |> g] is exactly equivalent
to [g (f (x))].
Left-associative operator, see {!Ocaml_operators} for more information.
@since 4.01
*)external(@@):('a->'b)->'a->'b="%apply"(** Application operator: [g @@ f @@ x] is exactly equivalent to
[g (f (x))].
Right-associative operator, see {!Ocaml_operators} for more information.
@since 4.01
*)(** {1 Integer arithmetic} *)(** Integers are [Sys.int_size] bits wide.
All operations are taken modulo 2{^[Sys.int_size]}.
They do not fail on overflow. *)external(~-):int->int="%negint"(** Unary negation. You can also write [- e] instead of [~- e].
Unary operator, see {!Ocaml_operators} for more information.
*)external(~+):int->int="%identity"(** Unary addition. You can also write [+ e] instead of [~+ e].
Unary operator, see {!Ocaml_operators} for more information.
@since 3.12.0
*)externalsucc:int->int="%succint"(** [succ x] is [x + 1]. *)externalpred:int->int="%predint"(** [pred x] is [x - 1]. *)external(+):int->int->int="%addint"(** Integer addition.
Left-associative operator, see {!Ocaml_operators} for more information.
*)external(-):int->int->int="%subint"(** Integer subtraction.
Left-associative operator, , see {!Ocaml_operators} for more information.
*)external(*):int->int->int="%mulint"(** Integer multiplication.
Left-associative operator, see {!Ocaml_operators} for more information.
*)external(/):int->int->int="%divint"(** Integer division.
Raise [Division_by_zero] if the second argument is 0.
Integer division rounds the real quotient of its arguments towards zero.
More precisely, if [x >= 0] and [y > 0], [x / y] is the greatest integer
less than or equal to the real quotient of [x] by [y]. Moreover,
[(- x) / y = x / (- y) = - (x / y)].
Left-associative operator, see {!Ocaml_operators} for more information.
*)external(mod):int->int->int="%modint"(** Integer remainder. If [y] is not zero, the result
of [x mod y] satisfies the following properties:
[x = (x / y) * y + x mod y] and
[abs(x mod y) <= abs(y) - 1].
If [y = 0], [x mod y] raises [Division_by_zero].
Note that [x mod y] is negative only if [x < 0].
Raise [Division_by_zero] if [y] is zero.
Left-associative operator, see {!Ocaml_operators} for more information.
*)valabs:int->int(** Return the absolute value of the argument. Note that this may be
negative if the argument is [min_int]. *)valmax_int:int(** The greatest representable integer. *)valmin_int:int(** The smallest representable integer. *)(** {2 Bitwise operations} *)external(land):int->int->int="%andint"(** Bitwise logical and.
Left-associative operator, see {!Ocaml_operators} for more information.
*)external(lor):int->int->int="%orint"(** Bitwise logical or.
Left-associative operator, see {!Ocaml_operators} for more information.
*)external(lxor):int->int->int="%xorint"(** Bitwise logical exclusive or.
Left-associative operator, see {!Ocaml_operators} for more information.
*)vallnot:int->int(** Bitwise logical negation. *)external(lsl):int->int->int="%lslint"(** [n lsl m] shifts [n] to the left by [m] bits.
The result is unspecified if [m < 0] or [m > Sys.int_size].
Right-associative operator, see {!Ocaml_operators} for more information.
*)external(lsr):int->int->int="%lsrint"(** [n lsr m] shifts [n] to the right by [m] bits.
This is a logical shift: zeroes are inserted regardless of
the sign of [n].
The result is unspecified if [m < 0] or [m > Sys.int_size].
Right-associative operator, see {!Ocaml_operators} for more information.
*)external(asr):int->int->int="%asrint"(** [n asr m] shifts [n] to the right by [m] bits.
This is an arithmetic shift: the sign bit of [n] is replicated.
The result is unspecified if [m < 0] or [m > Sys.int_size].
Right-associative operator, see {!Ocaml_operators} for more information.
*)(** {1 String operations}
More string operations are provided in module {!String}.
*)val(^):string->string->string(** String concatenation.
Right-associative operator, see {!Ocaml_operators} for more information.
*)(** {1 Character operations}
More character operations are provided in module {!Char}.
*)externalint_of_char:char->int="%identity"(** Return the ASCII code of the argument. *)valchar_of_int:int->char(** Return the character with the given ASCII code.
Raise [Invalid_argument "char_of_int"] if the argument is
outside the range 0--255. *)(** {1 Unit operations} *)externalignore:'a->unit="%ignore"(** Discard the value of its argument and return [()].
For instance, [ignore(f x)] discards the result of
the side-effecting function [f]. It is equivalent to
[f x; ()], except that the latter may generate a
compiler warning; writing [ignore(f x)] instead
avoids the warning. *)(** {1 String conversion functions} *)valstring_of_bool:bool->string(** Return the string representation of a boolean. As the returned values
may be shared, the user should not modify them directly.
*)valbool_of_string_opt:string->booloption(** Convert the given string to a boolean.
Return [None] if the string is not ["true"] or ["false"].
@since 4.05
*)valstring_of_int:int->string(** Return the string representation of an integer, in decimal. *)valint_of_string_opt:string->intoption(** Convert the given string to an integer.
The string is read in decimal (by default, or if the string
begins with [0u]), in hexadecimal (if it begins with [0x] or
[0X]), in octal (if it begins with [0o] or [0O]), or in binary
(if it begins with [0b] or [0B]).
The [0u] prefix reads the input as an unsigned integer in the range
[[0, 2*max_int+1]]. If the input exceeds {!max_int}
it is converted to the signed integer
[min_int + input - max_int - 1].
The [_] (underscore) character can appear anywhere in the string
and is ignored.
Return [None] if the given string is not a valid representation of an
integer, or if the integer represented exceeds the range of integers
representable in type [int].
@since 4.05
*)(** {1 Pair operations} *)externalfst:'a*'b->'a="%field0"(** Return the first component of a pair. *)externalsnd:'a*'b->'b="%field1"(** Return the second component of a pair. *)(** {1 List operations}
More list operations are provided in module {!List}.
*)val(@):'alist->'alist->'alist(** List concatenation. Not tail-recursive (length of the first argument).
Right-associative operator, see {!Ocaml_operators} for more information.
*)(** {1 References} *)type'aref={mutablecontents:'a}(** The type of references (mutable indirection cells) containing
a value of type ['a]. *)externalref:'a->'aref="%makemutable"(** Return a fresh reference containing the given value. *)external(!):'aref->'a="%field0"(** [!r] returns the current contents of reference [r].
Equivalent to [fun r -> r.contents].
Unary operator, see {!Ocaml_operators} for more information.
*)external(:=):'aref->'a->unit="%setfield0"(** [r := a] stores the value of [a] in reference [r].
Equivalent to [fun r v -> r.contents <- v].
Right-associative operator, see {!Ocaml_operators} for more information.
*)externalincr:intref->unit="%incr"(** Increment the integer contained in the given reference.
Equivalent to [fun r -> r := succ !r]. *)externaldecr:intref->unit="%decr"(** Decrement the integer contained in the given reference.
Equivalent to [fun r -> r := pred !r]. *)(** {1 Result type} *)(** @since 4.03.0 *)type('a,'b)result=Okof'a|Errorof'b(** {1 Operations on format strings} *)(** Format strings are character strings with special lexical conventions
that defines the functionality of formatted input/output functions. Format
strings are used to read data with formatted input functions from module
{!Scanf} and to print data with formatted output functions from modules
{!Printf} and {!Format}.
Format strings are made of three kinds of entities:
- {e conversions specifications}, introduced by the special character ['%']
followed by one or more characters specifying what kind of argument to
read or print,
- {e formatting indications}, introduced by the special character ['@']
followed by one or more characters specifying how to read or print the
argument,
- {e plain characters} that are regular characters with usual lexical
conventions. Plain characters specify string literals to be read in the
input or printed in the output.
There is an additional lexical rule to escape the special characters ['%']
and ['@'] in format strings: if a special character follows a ['%']
character, it is treated as a plain character. In other words, ["%%"] is
considered as a plain ['%'] and ["%@"] as a plain ['@'].
For more information about conversion specifications and formatting
indications available, read the documentation of modules {!Scanf},
{!Printf} and {!Format}.
*)(** Format strings have a general and highly polymorphic type
[('a, 'b, 'c, 'd, 'e, 'f) format6].
The two simplified types, [format] and [format4] below are
included for backward compatibility with earlier releases of
OCaml.
The meaning of format string type parameters is as follows:
- ['a] is the type of the parameters of the format for formatted output
functions ([printf]-style functions);
['a] is the type of the values read by the format for formatted input
functions ([scanf]-style functions).
- ['b] is the type of input source for formatted input functions and the
type of output target for formatted output functions.
For [printf]-style functions from module {!Printf}, ['b] is typically
[out_channel];
for [printf]-style functions from module {!Format}, ['b] is typically
{!Format.formatter};
for [scanf]-style functions from module {!Scanf}, ['b] is typically
{!Scanf.Scanning.in_channel}.
Type argument ['b] is also the type of the first argument given to
user's defined printing functions for [%a] and [%t] conversions,
and user's defined reading functions for [%r] conversion.
- ['c] is the type of the result of the [%a] and [%t] printing
functions, and also the type of the argument transmitted to the
first argument of [kprintf]-style functions or to the
[kscanf]-style functions.
- ['d] is the type of parameters for the [scanf]-style functions.
- ['e] is the type of the receiver function for the [scanf]-style functions.
- ['f] is the final result type of a formatted input/output function
invocation: for the [printf]-style functions, it is typically [unit];
for the [scanf]-style functions, it is typically the result type of the
receiver function.
*)type('a,'b,'c,'d,'e,'f)format6=('a,'b,'c,'d,'e,'f)CamlinternalFormatBasics.format6type('a,'b,'c,'d)format4=('a,'b,'c,'c,'c,'d)format6type('a,'b,'c)format=('a,'b,'c,'c)format4valstring_of_format:('a,'b,'c,'d,'e,'f)format6->string(** Converts a format string into a string. *)externalformat_of_string:('a,'b,'c,'d,'e,'f)format6->('a,'b,'c,'d,'e,'f)format6="%identity"(** [format_of_string s] returns a format string read from the string
literal [s].
Note: [format_of_string] can not convert a string argument that is not a
literal. If you need this functionality, use the more general
{!Scanf.format_from_string} function.
*)val(^^):('a,'b,'c,'d,'e,'f)format6->('f,'b,'c,'e,'g,'h)format6->('a,'b,'c,'d,'g,'h)format6(** [f1 ^^ f2] catenates format strings [f1] and [f2]. The result is a
format string that behaves as the concatenation of format strings [f1] and
[f2]: in case of formatted output, it accepts arguments from [f1], then
arguments from [f2]; in case of formatted input, it returns results from
[f1], then results from [f2].
Right-associative operator, see {!Ocaml_operators} for more information.
*)end# 6 "v8.in.ml"openPervasivesmoduleEither:sig# 1 "v8/either.mli"(**************************************************************************)(* *)(* OCaml *)(* *)(* Gabriel Scherer, projet Parsifal, INRIA Saclay *)(* *)(* Copyright 2019 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the GNU Lesser General Public License version 2.1, with the *)(* special exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)(** Either type.
Either is the simplest and most generic sum/variant type:
a value of [('a, 'b) Either.t] is either a [Left (v : 'a)]
or a [Right (v : 'b)].
It is a natural choice in the API of generic functions where values
could fall in two different cases, possibly at different types,
without assigning a specific meaning to what each case should be.
For example:
{[List.partition_map:
('a -> ('b, 'c) Either.t) -> 'a list -> 'b list * 'c list]}
If you are looking for a parametrized type where
one alternative means success and the other means failure,
you should use the more specific type {!Result.t}.
@since 4.12
*)(* Unlike [result], no [either] type is made available in Stdlib,
one needs to access [Either.t] explicitly:
- This type is less common in typical OCaml codebases,
which prefer domain-specific variant types whose constructors
carry more meaning.
- Adding this to Stdlib would raise warnings in existing codebases
that already use a constructor named Left or Right:
+ when opening a module that exports such a name,
warning 45 is raised
+ adding a second constructor of the same name in scope kicks
in the disambiguation mechanisms, and warning 41 may now
be raised by existing code.
If the use becomes more common in the future we can always
revisit this choice.
*)type('a,'b)t=Leftof'a|Rightof'b(**)(** A value of [('a, 'b) Either.t] contains
either a value of ['a] or a value of ['b] *)(* some values omitted *)valequal:left:('a->'a->bool)->right:('b->'b->bool)->('a,'b)t->('a,'b)t->bool(** [equal ~left ~right e0 e1] tests equality of [e0] and [e1] using [left]
and [right] to respectively compare values wrapped by [Left _] and
[Right _]. *)valcompare:left:('a->'a->int)->right:('b->'b->int)->('a,'b)t->('a,'b)t->int(** [compare ~left ~right e0 e1] totally orders [e0] and [e1] using [left] and
[right] to respectively compare values wrapped by [Left _ ] and [Right _].
[Left _] values are smaller than [Right _] values. *)end# 10 "v8.in.ml"moduleString:sig# 1 "v8/string.mli"(**************************************************************************)(* *)(* OCaml *)(* *)(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)(* *)(* Copyright 1996 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the GNU Lesser General Public License version 2.1, with the *)(* special exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)(** String operations.
A string is an immutable data structure that contains a
fixed-length sequence of (single-byte) characters. Each character
can be accessed in constant time through its index.
Given a string [s] of length [l], we can access each of the [l]
characters of [s] via its index in the sequence. Indexes start at
[0], and we will call an index valid in [s] if it falls within the
range [[0...l-1]] (inclusive). A position is the point between two
characters or at the beginning or end of the string. We call a
position valid in [s] if it falls within the range [[0...l]]
(inclusive). Note that the character at index [n] is between
positions [n] and [n+1].
Two parameters [start] and [len] are said to designate a valid
substring of [s] if [len >= 0] and [start] and [start+len] are
valid positions in [s].
Note: OCaml strings used to be modifiable in place, for instance via
the {!String.set} and {!String.blit} functions described below. This
usage is only possible when the compiler is put in "unsafe-string"
mode by giving the [-unsafe-string] command-line option. This
compatibility mode makes the types [string] and [bytes] (see module
{!Bytes}) interchangeable so that functions expecting byte sequences
can also accept strings as arguments and modify them.
The distinction between [bytes] and [string] was introduced in OCaml
4.02, and the "unsafe-string" compatibility mode was the default
until OCaml 4.05. Starting with 4.06, the compatibility mode is
opt-in; we intend to remove the option in the future.
*)externallength:string->int="%string_length"(** Return the length (number of characters) of the given string. *)externalget:string->int->char="%string_safe_get"(** [String.get s n] returns the character at index [n] in string [s].
You can also write [s.[n]] instead of [String.get s n].
Raise [Invalid_argument] if [n] not a valid index in [s]. *)valmake:int->char->string(** [String.make n c] returns a fresh string of length [n],
filled with the character [c].
Raise [Invalid_argument] if [n < 0] or [n > ]{!Sys.max_string_length}. *)valinit:int->(int->char)->string(** [String.init n f] returns a string of length [n], with character
[i] initialized to the result of [f i] (called in increasing
index order).
Raise [Invalid_argument] if [n < 0] or [n > ]{!Sys.max_string_length}.
@since 4.02.0
*)valsub:string->int->int->string(** [String.sub s start len] returns a fresh string of length [len],
containing the substring of [s] that starts at position [start] and
has length [len].
Raise [Invalid_argument] if [start] and [len] do not
designate a valid substring of [s]. *)valblit:string->int->bytes->int->int->unit(** Same as {!Bytes.blit_string}. *)valconcat:string->stringlist->string(** [String.concat sep sl] concatenates the list of strings [sl],
inserting the separator string [sep] between each.
Raise [Invalid_argument] if the result is longer than
{!Sys.max_string_length} bytes. *)valiter:(char->unit)->string->unit(** [String.iter f s] applies function [f] in turn to all
the characters of [s]. It is equivalent to
[f s.[0]; f s.[1]; ...; f s.[String.length s - 1]; ()]. *)valiteri:(int->char->unit)->string->unit(** Same as {!String.iter}, but the
function is applied to the index of the element as first argument
(counting from 0), and the character itself as second argument.
@since 4.00.0 *)valmap:(char->char)->string->string(** [String.map f s] applies function [f] in turn to all the
characters of [s] (in increasing index order) and stores the
results in a new string that is returned.
@since 4.00.0 *)valmapi:(int->char->char)->string->string(** [String.mapi f s] calls [f] with each character of [s] and its
index (in increasing index order) and stores the results in a new
string that is returned.
@since 4.02.0 *)valtrim:string->string(** Return a copy of the argument, without leading and trailing
whitespace. The characters regarded as whitespace are: [' '],
['\012'], ['\n'], ['\r'], and ['\t']. If there is neither leading nor
trailing whitespace character in the argument, return the original
string itself, not a copy.
@since 4.00.0 *)valescaped:string->string(** Return a copy of the argument, with special characters
represented by escape sequences, following the lexical
conventions of OCaml.
All characters outside the ASCII printable range (32..126) are
escaped, as well as backslash and double-quote.
If there is no special character in the argument that needs
escaping, return the original string itself, not a copy.
Raise [Invalid_argument] if the result is longer than
{!Sys.max_string_length} bytes.
The function {!Scanf.unescaped} is a left inverse of [escaped],
i.e. [Scanf.unescaped (escaped s) = s] for any string [s] (unless
[escape s] fails). *)valindex_opt:string->char->intoption(** [String.index_opt s c] returns the index of the first
occurrence of character [c] in string [s], or
[None] if [c] does not occur in [s].
@since 4.05 *)valrindex_opt:string->char->intoption(** [String.rindex_opt s c] returns the index of the last occurrence
of character [c] in string [s], or [None] if [c] does not occur in
[s].
@since 4.05 *)valindex_from_opt:string->int->char->intoption(** [String.index_from_opt s i c] returns the index of the
first occurrence of character [c] in string [s] after position [i]
or [None] if [c] does not occur in [s] after position [i].
[String.index_opt s c] is equivalent to [String.index_from_opt s 0 c].
Raise [Invalid_argument] if [i] is not a valid position in [s].
@since 4.05
*)valrindex_from_opt:string->int->char->intoption(** [String.rindex_from_opt s i c] returns the index of the
last occurrence of character [c] in string [s] before position [i+1]
or [None] if [c] does not occur in [s] before position [i+1].
[String.rindex_opt s c] is equivalent to
[String.rindex_from_opt s (String.length s - 1) c].
Raise [Invalid_argument] if [i+1] is not a valid position in [s].
@since 4.05
*)valcontains:string->char->bool(** [String.contains s c] tests if character [c]
appears in the string [s]. *)valcontains_from:string->int->char->bool(** [String.contains_from s start c] tests if character [c]
appears in [s] after position [start].
[String.contains s c] is equivalent to
[String.contains_from s 0 c].
Raise [Invalid_argument] if [start] is not a valid position in [s]. *)valrcontains_from:string->int->char->bool(** [String.rcontains_from s stop c] tests if character [c]
appears in [s] before position [stop+1].
Raise [Invalid_argument] if [stop < 0] or [stop+1] is not a valid
position in [s]. *)valuppercase_ascii:string->string(** Return a copy of the argument, with all lowercase letters
translated to uppercase, using the US-ASCII character set.
@since 4.03.0 *)vallowercase_ascii:string->string(** Return a copy of the argument, with all uppercase letters
translated to lowercase, using the US-ASCII character set.
@since 4.03.0 *)valcapitalize_ascii:string->string(** Return a copy of the argument, with the first character set to uppercase,
using the US-ASCII character set.
@since 4.03.0 *)valuncapitalize_ascii:string->string(** Return a copy of the argument, with the first character set to lowercase,
using the US-ASCII character set.
@since 4.03.0 *)typet=string(** An alias for the type of strings. *)valcompare:t->t->int(** The comparison function for strings, with the same specification as
{!Stdlib.compare}. Along with the type [t], this function [compare]
allows the module [String] to be passed as argument to the functors
{!Set.Make} and {!Map.Make}. *)valequal:t->t->bool(** The equal function for strings.
@since 4.03.0 *)valsplit_on_char:char->string->stringlist(** [String.split_on_char sep s] returns the list of all (possibly empty)
substrings of [s] that are delimited by the [sep] character.
The function's output is specified by the following invariants:
- The list is not empty.
- Concatenating its elements using [sep] as a separator returns a
string equal to the input ([String.concat (String.make 1 sep)
(String.split_on_char sep s) = s]).
- No string in the result contains the [sep] character.
@since 4.04.0
*)end# 12 "v8.in.ml"moduleChar:sig# 1 "v8/char.mli"(**************************************************************************)(* *)(* OCaml *)(* *)(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)(* *)(* Copyright 1996 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the GNU Lesser General Public License version 2.1, with the *)(* special exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)(** Character operations. *)externalcode:char->int="%identity"(** Return the ASCII code of the argument. *)valchr:int->char(** Return the character with the given ASCII code.
@raise Invalid_argument if the argument is
outside the range 0--255. *)valescaped:char->string(** Return a string representing the given character,
with special characters escaped following the lexical conventions
of OCaml.
All characters outside the ASCII printable range (32..126) are
escaped, as well as backslash, double-quote, and single-quote. *)vallowercase_ascii:char->char(** Convert the given character to its equivalent lowercase character,
using the US-ASCII character set.
@since 4.03.0 *)valuppercase_ascii:char->char(** Convert the given character to its equivalent uppercase character,
using the US-ASCII character set.
@since 4.03.0 *)typet=char(** An alias for the type of characters. *)valcompare:t->t->int(** The comparison function for characters, with the same specification as
{!Stdlib.compare}. Along with the type [t], this function [compare]
allows the module [Char] to be passed as argument to the functors
{!Set.Make} and {!Map.Make}. *)valequal:t->t->bool(** The equal function for chars.
@since 4.03.0 *)end# 14 "v8.in.ml"moduleBytes:sig# 1 "v8/bytes.mli"(**************************************************************************)(* *)(* OCaml *)(* *)(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)(* *)(* Copyright 1996 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* Copyright (c) 2022 DaiLambda, Inc. <contact@dailambda,jp> *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the GNU Lesser General Public License version 2.1, with the *)(* special exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)(** Byte sequence operations.
A byte sequence is a mutable data structure that contains a
fixed-length sequence of bytes. Each byte can be indexed in
constant time for reading or writing.
Given a byte sequence [s] of length [l], we can access each of the
[l] bytes of [s] via its index in the sequence. Indexes start at
[0], and we will call an index valid in [s] if it falls within the
range [[0...l-1]] (inclusive). A position is the point between two
bytes or at the beginning or end of the sequence. We call a
position valid in [s] if it falls within the range [[0...l]]
(inclusive). Note that the byte at index [n] is between positions
[n] and [n+1].
Two parameters [start] and [len] are said to designate a valid
range of [s] if [len >= 0] and [start] and [start+len] are valid
positions in [s].
Byte sequences can be modified in place, for instance via the [set]
and [blit] functions described below. See also strings (module
{!String}), which are almost the same data structure, but cannot be
modified in place.
Bytes are represented by the OCaml type [char].
The labeled version of this module can be used as described in the
{!StdLabels} module.
@since 4.02.0
*)externallength:bytes->int="%bytes_length"(** Return the length (number of bytes) of the argument. *)externalget:bytes->int->char="%bytes_safe_get"(** [get s n] returns the byte at index [n] in argument [s].
@raise Invalid_argument if [n] is not a valid index in [s]. *)externalset:bytes->int->char->unit="%bytes_safe_set"(** [set s n c] modifies [s] in place, replacing the byte at index [n]
with [c].
@raise Invalid_argument if [n] is not a valid index in [s]. *)valmake:int->char->bytes(** [make n c] returns a new byte sequence of length [n], filled with
the byte [c].
@raise Invalid_argument if [n < 0] or [n > ]{!Sys.max_string_length}. *)valinit:int->(int->char)->bytes(** [init n f] returns a fresh byte sequence of length [n],
with character [i] initialized to the result of [f i] (in increasing
index order).
@raise Invalid_argument if [n < 0] or [n > ]{!Sys.max_string_length}. *)valempty:bytes(** A byte sequence of size 0. *)valcopy:bytes->bytes(** Return a new byte sequence that contains the same bytes as the
argument. *)valof_string:string->bytes(** Return a new byte sequence that contains the same bytes as the
given string. *)valto_string:bytes->string(** Return a new string that contains the same bytes as the given byte
sequence. *)valsub:bytes->int->int->bytes(** [sub s pos len] returns a new byte sequence of length [len],
containing the subsequence of [s] that starts at position [pos]
and has length [len].
@raise Invalid_argument if [pos] and [len] do not designate a
valid range of [s]. *)valsub_string:bytes->int->int->string(** Same as {!sub} but return a string instead of a byte sequence. *)valextend:bytes->int->int->bytes(** [extend s left right] returns a new byte sequence that contains
the bytes of [s], with [left] uninitialized bytes prepended and
[right] uninitialized bytes appended to it. If [left] or [right]
is negative, then bytes are removed (instead of appended) from
the corresponding side of [s].
@raise Invalid_argument if the result length is negative or
longer than {!Sys.max_string_length} bytes.
@since 4.05.0 in BytesLabels *)valfill:bytes->int->int->char->unit(** [fill s pos len c] modifies [s] in place, replacing [len]
characters with [c], starting at [pos].
@raise Invalid_argument if [pos] and [len] do not designate a
valid range of [s]. *)valblit:bytes->int->bytes->int->int->unit(** [blit src src_pos dst dst_pos len] copies [len] bytes from sequence
[src], starting at index [src_pos], to sequence [dst], starting at
index [dst_pos]. It works correctly even if [src] and [dst] are the
same byte sequence, and the source and destination intervals
overlap.
@raise Invalid_argument if [src_pos] and [len] do not
designate a valid range of [src], or if [dst_pos] and [len]
do not designate a valid range of [dst]. *)valblit_string:string->int->bytes->int->int->unit(** [blit src src_pos dst dst_pos len] copies [len] bytes from string
[src], starting at index [src_pos], to byte sequence [dst],
starting at index [dst_pos].
@raise Invalid_argument if [src_pos] and [len] do not
designate a valid range of [src], or if [dst_pos] and [len]
do not designate a valid range of [dst].
@since 4.05.0 in BytesLabels *)valconcat:bytes->byteslist->bytes(** [concat sep sl] concatenates the list of byte sequences [sl],
inserting the separator byte sequence [sep] between each, and
returns the result as a new byte sequence.
@raise Invalid_argument if the result is longer than
{!Sys.max_string_length} bytes.
*)valcat:bytes->bytes->bytes(** [cat s1 s2] concatenates [s1] and [s2] and returns the result
as a new byte sequence.
@raise Invalid_argument if the result is longer than
{!Sys.max_string_length} bytes.
@since 4.05.0 in BytesLabels *)valiter:(char->unit)->bytes->unit(** [iter f s] applies function [f] in turn to all the bytes of [s].
It is equivalent to [f (get s 0); f (get s 1); ...; f (get s
(length s - 1)); ()]. *)valiteri:(int->char->unit)->bytes->unit(** Same as {!iter}, but the function is applied to the index of
the byte as first argument and the byte itself as second
argument. *)valmap:(char->char)->bytes->bytes(** [map f s] applies function [f] in turn to all the bytes of [s] (in
increasing index order) and stores the resulting bytes in a new sequence
that is returned as the result. *)valmapi:(int->char->char)->bytes->bytes(** [mapi f s] calls [f] with each character of [s] and its
index (in increasing index order) and stores the resulting bytes
in a new sequence that is returned as the result. *)valtrim:bytes->bytes(** Return a copy of the argument, without leading and trailing
whitespace. The bytes regarded as whitespace are the ASCII
characters [' '], ['\012'], ['\n'], ['\r'], and ['\t']. *)valescaped:bytes->bytes(** Return a copy of the argument, with special characters represented
by escape sequences, following the lexical conventions of OCaml.
All characters outside the ASCII printable range (32..126) are
escaped, as well as backslash and double-quote.
@raise Invalid_argument if the result is longer than
{!Sys.max_string_length} bytes. *)valindex_opt:bytes->char->intoption(** [index_opt s c] returns the index of the first occurrence of byte [c]
in [s] or [None] if [c] does not occur in [s].
@since 4.05 *)valrindex_opt:bytes->char->intoption(** [rindex_opt s c] returns the index of the last occurrence of byte [c]
in [s] or [None] if [c] does not occur in [s].
@since 4.05 *)valindex_from_opt:bytes->int->char->intoption(** [index_from_opt s i c] returns the index of the first occurrence of
byte [c] in [s] after position [i] or [None] if [c] does not occur in [s]
after position [i].
[index_opt s c] is equivalent to [index_from_opt s 0 c].
@raise Invalid_argument if [i] is not a valid position in [s].
@since 4.05 *)valrindex_from_opt:bytes->int->char->intoption(** [rindex_from_opt s i c] returns the index of the last occurrence
of byte [c] in [s] before position [i+1] or [None] if [c] does not
occur in [s] before position [i+1]. [rindex_opt s c] is equivalent to
[rindex_from s (length s - 1) c].
@raise Invalid_argument if [i+1] is not a valid position in [s].
@since 4.05 *)valcontains:bytes->char->bool(** [contains s c] tests if byte [c] appears in [s]. *)valcontains_from:bytes->int->char->bool(** [contains_from s start c] tests if byte [c] appears in [s] after
position [start]. [contains s c] is equivalent to [contains_from
s 0 c].
@raise Invalid_argument if [start] is not a valid position in [s]. *)valrcontains_from:bytes->int->char->bool(** [rcontains_from s stop c] tests if byte [c] appears in [s] before
position [stop+1].
@raise Invalid_argument if [stop < 0] or [stop+1] is not a valid
position in [s]. *)valuppercase_ascii:bytes->bytes(** Return a copy of the argument, with all lowercase letters
translated to uppercase, using the US-ASCII character set.
@since 4.03.0 (4.05.0 in BytesLabels) *)vallowercase_ascii:bytes->bytes(** Return a copy of the argument, with all uppercase letters
translated to lowercase, using the US-ASCII character set.
@since 4.03.0 (4.05.0 in BytesLabels) *)valcapitalize_ascii:bytes->bytes(** Return a copy of the argument, with the first character set to uppercase,
using the US-ASCII character set.
@since 4.03.0 (4.05.0 in BytesLabels) *)valuncapitalize_ascii:bytes->bytes(** Return a copy of the argument, with the first character set to lowercase,
using the US-ASCII character set.
@since 4.03.0 (4.05.0 in BytesLabels) *)typet=bytes(** An alias for the type of byte sequences. *)valcompare:t->t->int(** The comparison function for byte sequences, with the same
specification as {!Stdlib.compare}. Along with the type [t],
this function [compare] allows the module [Bytes] to be passed as
argument to the functors {!Set.Make} and {!Map.Make}. *)valequal:t->t->bool(** The equality function for byte sequences.
@since 4.03.0 (4.05.0 in BytesLabels) *)(** Bitwise AND on bytes.
If the arguments have different lengths, the prefix of the longer bytes
is cut to have the same length as the shorter one before taking bitwise
AND.
ex. 0xff0f AND 0xff = 0x0f AND 0xff = 0x0f
*)vallogand:bytes->bytes->bytes(** Bitwise OR on bytes.
If the arguments have different lengths, the shorter bytes is 0-padded
on the left to have the same length before taking bitwise OR.
ex. 0xf000 OR 0x0f = 0xf000 OR 0x000f = 0xf00f
*)vallogor:bytes->bytes->bytes(** Bitwise XOR on bytes.
If the arguments have different lengths, the shorter bytes is 0-padded
on the left to have the same length before taking bitwise XOR.
ex. 0xf0ff XOR 0x0f = 0xf0ff XOR 0x000f = 0xf0f0
*)vallogxor:bytes->bytes->bytes(** Bitwise NOT on bytes.
ex. NOT 0xf0f0 = 0x0f0f
*)vallognot:bytes->bytes(** Logical shift left on bytes, using big-endian encoding.
[shift_left bs nbits] returns a [bytes] longer than [bs] when [nbits > 0].
It raises [Invalid_argument "shift_left"] when [nbits < 0].
ex. 0x1234 LSL 0 = 0x1234
0x1234 LSL 1 = 0x002468 (not 0x2468)
0x1234 LSL 8 = 0x123400
0x001234 LSL 1 = 0x00002468 (not 0x002468)
0x (empty bytes) LSL 1 = 0x00
*)valshift_left:bytes->int->bytes(** Logical shift right on bytes, using big-endian encoding.
[shift_right bs nbits] raises [Invalid_argument "shift_right"]
when [nbits < 0].
ex. 0x1234 LSR 0 = 0x1234
0x1234 LSR 1 = 0x091a
0x1234 LSR 8 = 0x12 (not 0x0012)
0x123499 LSR 9 = 0x091a
*)valshift_right:bytes->int->bytesend# 16 "v8.in.ml"moduleInt32:sig# 1 "v8/int32.mli"(**************************************************************************)(* *)(* OCaml *)(* *)(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)(* *)(* Copyright 1996 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the GNU Lesser General Public License version 2.1, with the *)(* special exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)(** 32-bit integers.
This module provides operations on the type [int32]
of signed 32-bit integers. Unlike the built-in [int] type,
the type [int32] is guaranteed to be exactly 32-bit wide on all
platforms. All arithmetic operations over [int32] are taken
modulo 2{^32}.
Performance notice: values of type [int32] occupy more memory
space than values of type [int], and arithmetic operations on
[int32] are generally slower than those on [int]. Use [int32]
only when the application requires exact 32-bit arithmetic.
Literals for 32-bit integers are suffixed by l:
{[
let zero: int32 = 0l
let one: int32 = 1l
let m_one: int32 = -1l
]}
*)valzero:int32(** The 32-bit integer 0. *)valone:int32(** The 32-bit integer 1. *)valminus_one:int32(** The 32-bit integer -1. *)externalneg:int32->int32="%int32_neg"(** Unary negation. *)externaladd:int32->int32->int32="%int32_add"(** Addition. *)externalsub:int32->int32->int32="%int32_sub"(** Subtraction. *)externalmul:int32->int32->int32="%int32_mul"(** Multiplication. *)externaldiv:int32->int32->int32="%int32_div"(** Integer division. This division rounds the real quotient of
its arguments towards zero, as specified for {!Stdlib.(/)}.
@raise Division_by_zero if the second
argument is zero. *)externalrem:int32->int32->int32="%int32_mod"(** Integer remainder. If [y] is not zero, the result
of [Int32.rem x y] satisfies the following property:
[x = Int32.add (Int32.mul (Int32.div x y) y) (Int32.rem x y)].
If [y = 0], [Int32.rem x y] raises [Division_by_zero]. *)valsucc:int32->int32(** Successor. [Int32.succ x] is [Int32.add x Int32.one]. *)valpred:int32->int32(** Predecessor. [Int32.pred x] is [Int32.sub x Int32.one]. *)valabs:int32->int32(** Return the absolute value of its argument. *)valmax_int:int32(** The greatest representable 32-bit integer, 2{^31} - 1. *)valmin_int:int32(** The smallest representable 32-bit integer, -2{^31}. *)externallogand:int32->int32->int32="%int32_and"(** Bitwise logical and. *)externallogor:int32->int32->int32="%int32_or"(** Bitwise logical or. *)externallogxor:int32->int32->int32="%int32_xor"(** Bitwise logical exclusive or. *)vallognot:int32->int32(** Bitwise logical negation. *)externalshift_left:int32->int->int32="%int32_lsl"(** [Int32.shift_left x y] shifts [x] to the left by [y] bits.
The result is unspecified if [y < 0] or [y >= 32]. *)externalshift_right:int32->int->int32="%int32_asr"(** [Int32.shift_right x y] shifts [x] to the right by [y] bits.
This is an arithmetic shift: the sign bit of [x] is replicated
and inserted in the vacated bits.
The result is unspecified if [y < 0] or [y >= 32]. *)externalshift_right_logical:int32->int->int32="%int32_lsr"(** [Int32.shift_right_logical x y] shifts [x] to the right by [y] bits.
This is a logical shift: zeroes are inserted in the vacated bits
regardless of the sign of [x].
The result is unspecified if [y < 0] or [y >= 32]. *)externalof_int:int->int32="%int32_of_int"(** Convert the given integer (type [int]) to a 32-bit integer
(type [int32]). On 64-bit platforms, the argument is taken
modulo 2{^32}. *)externalto_int:int32->int="%int32_to_int"(** Convert the given 32-bit integer (type [int32]) to an
integer (type [int]). On 32-bit platforms, the 32-bit integer
is taken modulo 2{^31}, i.e. the high-order bit is lost
during the conversion. On 64-bit platforms, the conversion
is exact. *)valof_string_opt:string->int32option(** Same as [of_string], but return [None] instead of raising.
@since 4.05 *)valto_string:int32->string(** Return the string representation of its argument, in signed decimal. *)typet=int32(** An alias for the type of 32-bit integers. *)valcompare:t->t->int(** The comparison function for 32-bit integers, with the same specification as
{!Stdlib.compare}. Along with the type [t], this function [compare]
allows the module [Int32] to be passed as argument to the functors
{!Set.Make} and {!Map.Make}. *)valequal:t->t->bool(** The equal function for int32s.
@since 4.03.0 *)end# 18 "v8.in.ml"moduleInt64:sig# 1 "v8/int64.mli"(**************************************************************************)(* *)(* OCaml *)(* *)(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)(* *)(* Copyright 1996 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the GNU Lesser General Public License version 2.1, with the *)(* special exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)(** 64-bit integers.
This module provides operations on the type [int64] of
signed 64-bit integers. Unlike the built-in [int] type,
the type [int64] is guaranteed to be exactly 64-bit wide on all
platforms. All arithmetic operations over [int64] are taken
modulo 2{^64}
Performance notice: values of type [int64] occupy more memory
space than values of type [int], and arithmetic operations on
[int64] are generally slower than those on [int]. Use [int64]
only when the application requires exact 64-bit arithmetic.
Literals for 64-bit integers are suffixed by L:
{[
let zero: int64 = 0L
let one: int64 = 1L
let m_one: int64 = -1L
]}
*)valzero:int64(** The 64-bit integer 0. *)valone:int64(** The 64-bit integer 1. *)valminus_one:int64(** The 64-bit integer -1. *)externalneg:int64->int64="%int64_neg"(** Unary negation. *)externaladd:int64->int64->int64="%int64_add"(** Addition. *)externalsub:int64->int64->int64="%int64_sub"(** Subtraction. *)externalmul:int64->int64->int64="%int64_mul"(** Multiplication. *)externaldiv:int64->int64->int64="%int64_div"(** Integer division.
@raise Division_by_zero if the second
argument is zero. This division rounds the real quotient of
its arguments towards zero, as specified for {!Stdlib.(/)}. *)externalrem:int64->int64->int64="%int64_mod"(** Integer remainder. If [y] is not zero, the result
of [Int64.rem x y] satisfies the following property:
[x = Int64.add (Int64.mul (Int64.div x y) y) (Int64.rem x y)].
If [y = 0], [Int64.rem x y] raises [Division_by_zero]. *)valsucc:int64->int64(** Successor. [Int64.succ x] is [Int64.add x Int64.one]. *)valpred:int64->int64(** Predecessor. [Int64.pred x] is [Int64.sub x Int64.one]. *)valabs:int64->int64(** Return the absolute value of its argument. *)valmax_int:int64(** The greatest representable 64-bit integer, 2{^63} - 1. *)valmin_int:int64(** The smallest representable 64-bit integer, -2{^63}. *)externallogand:int64->int64->int64="%int64_and"(** Bitwise logical and. *)externallogor:int64->int64->int64="%int64_or"(** Bitwise logical or. *)externallogxor:int64->int64->int64="%int64_xor"(** Bitwise logical exclusive or. *)vallognot:int64->int64(** Bitwise logical negation. *)externalshift_left:int64->int->int64="%int64_lsl"(** [Int64.shift_left x y] shifts [x] to the left by [y] bits.
The result is unspecified if [y < 0] or [y >= 64]. *)externalshift_right:int64->int->int64="%int64_asr"(** [Int64.shift_right x y] shifts [x] to the right by [y] bits.
This is an arithmetic shift: the sign bit of [x] is replicated
and inserted in the vacated bits.
The result is unspecified if [y < 0] or [y >= 64]. *)externalshift_right_logical:int64->int->int64="%int64_lsr"(** [Int64.shift_right_logical x y] shifts [x] to the right by [y] bits.
This is a logical shift: zeroes are inserted in the vacated bits
regardless of the sign of [x].
The result is unspecified if [y < 0] or [y >= 64]. *)externalof_int:int->int64="%int64_of_int"(** Convert the given integer (type [int]) to a 64-bit integer
(type [int64]). *)externalto_int:int64->int="%int64_to_int"(** Convert the given 64-bit integer (type [int64]) to an
integer (type [int]). On 64-bit platforms, the 64-bit integer
is taken modulo 2{^63}, i.e. the high-order bit is lost
during the conversion. On 32-bit platforms, the 64-bit integer
is taken modulo 2{^31}, i.e. the top 33 bits are lost
during the conversion. *)externalof_int32:int32->int64="%int64_of_int32"(** Convert the given 32-bit integer (type [int32])
to a 64-bit integer (type [int64]). *)externalto_int32:int64->int32="%int64_to_int32"(** Convert the given 64-bit integer (type [int64]) to a
32-bit integer (type [int32]). The 64-bit integer
is taken modulo 2{^32}, i.e. the top 32 bits are lost
during the conversion. *)valof_string_opt:string->int64option(** Same as [of_string], but return [None] instead of raising.
@since 4.05 *)valto_string:int64->string(** Return the string representation of its argument, in decimal. *)typet=int64(** An alias for the type of 64-bit integers. *)valcompare:t->t->int(** The comparison function for 64-bit integers, with the same specification as
{!Stdlib.compare}. Along with the type [t], this function [compare]
allows the module [Int64] to be passed as argument to the functors
{!Set.Make} and {!Map.Make}. *)valequal:t->t->bool(** The equal function for int64s.
@since 4.03.0 *)end# 20 "v8.in.ml"moduleFormat:sig# 1 "v8/format.mli"(**************************************************************************)(* *)(* OCaml *)(* *)(* Pierre Weis, projet Cristal, INRIA Rocquencourt *)(* *)(* Copyright 1996 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the GNU Lesser General Public License version 2.1, with the *)(* special exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)(** Pretty-printing.
This module implements a pretty-printing facility to format values
within {{!boxes}'pretty-printing boxes'} and {{!tags}'semantic tags'}
combined with a set of {{!fpp}printf-like functions}.
The pretty-printer splits lines at specified {{!breaks}break hints},
and indents lines according to the box structure.
Similarly, {{!tags}semantic tags} can be used to decouple text
presentation from its contents.
This pretty-printing facility is implemented as an overlay on top of
abstract {{!section:formatter}formatters} which provide basic output
functions.
Some formatters are predefined, notably:
- {!std_formatter} outputs to {{!Stdlib.stdout}stdout}
- {!err_formatter} outputs to {{!Stdlib.stderr}stderr}
Most functions in the {!Format} module come in two variants:
a short version that operates on {!std_formatter} and the
generic version prefixed by [pp_] that takes a formatter
as its first argument.
More formatters can be created with {!formatter_of_out_channel},
{!formatter_of_buffer}, {!formatter_of_symbolic_output_buffer}
or using {{!section:formatter}custom formatters}.
*)(** {1 Introduction}
For a gentle introduction to the basics of pretty-printing using
[Format], read
{{:http://caml.inria.fr/resources/doc/guides/format.en.html}
http://caml.inria.fr/resources/doc/guides/format.en.html}.
You may consider this module as providing an extension to the
[printf] facility to provide automatic line splitting. The addition of
pretty-printing annotations to your regular [printf] format strings gives
you fancy indentation and line breaks.
Pretty-printing annotations are described below in the documentation of
the function {!Format.fprintf}.
You may also use the explicit pretty-printing box management and printing
functions provided by this module. This style is more basic but more
verbose than the concise [fprintf] format strings.
For instance, the sequence
[open_box 0; print_string "x ="; print_space ();
print_int 1; close_box (); print_newline ()]
that prints [x = 1] within a pretty-printing box, can be
abbreviated as [printf "@[%s@ %i@]@." "x =" 1], or even shorter
[printf "@[x =@ %i@]@." 1].
Rule of thumb for casual users of this library:
- use simple pretty-printing boxes (as obtained by [open_box 0]);
- use simple break hints as obtained by [print_cut ()] that outputs a
simple break hint, or by [print_space ()] that outputs a space
indicating a break hint;
- once a pretty-printing box is open, display its material with basic
printing functions (e. g. [print_int] and [print_string]);
- when the material for a pretty-printing box has been printed, call
[close_box ()] to close the box;
- at the end of pretty-printing, flush the pretty-printer to display all
the remaining material, e.g. evaluate [print_newline ()].
The behavior of pretty-printing commands is unspecified
if there is no open pretty-printing box. Each box opened by
one of the [open_] functions below must be closed using [close_box]
for proper formatting. Otherwise, some of the material printed in the
boxes may not be output, or may be formatted incorrectly.
In case of interactive use, each phrase is executed in the initial state
of the standard pretty-printer: after each phrase execution, the
interactive system closes all open pretty-printing boxes, flushes all
pending text, and resets the standard pretty-printer.
Warning: mixing calls to pretty-printing functions of this module with
calls to {!Stdlib} low level output functions is error prone.
The pretty-printing functions output material that is delayed in the
pretty-printer queue and stacks in order to compute proper line
splitting. In contrast, basic I/O output functions write directly in
their output device. As a consequence, the output of a basic I/O function
may appear before the output of a pretty-printing function that has been
called before. For instance,
[
Stdlib.print_string "<";
Format.print_string "PRETTY";
Stdlib.print_string ">";
Format.print_string "TEXT";
]
leads to output [<>PRETTYTEXT].
*)typeformatter(** Abstract data corresponding to a pretty-printer (also called a
formatter) and all its machinery. See also {!section:formatter}. *)(** {1:boxes Pretty-printing boxes} *)(** The pretty-printing engine uses the concepts of pretty-printing box and
break hint to drive indentation and line splitting behavior of the
pretty-printer.
Each different pretty-printing box kind introduces a specific line splitting
policy:
- within an {e horizontal} box, break hints never split the line (but the
line may be split in a box nested deeper),
- within a {e vertical} box, break hints always split the line,
- within an {e horizontal/vertical} box, if the box fits on the current line
then break hints never split the line, otherwise break hint always split
the line,
- within a {e compacting} box, a break hint never splits the line,
unless there is no more room on the current line.
Note that line splitting policy is box specific: the policy of a box does
not rule the policy of inner boxes. For instance, if a vertical box is
nested in an horizontal box, all break hints within the vertical box will
split the line.
Moreover, opening a box after the {{!maxindent}maximum indentation limit}
splits the line whether or not the box would end up fitting on the line.
*)valpp_open_box:formatter->int->unit(** [pp_open_box ppf d] opens a new compacting pretty-printing box with
offset [d] in the formatter [ppf].
Within this box, the pretty-printer prints as much as possible material on
every line.
A break hint splits the line if there is no more room on the line to
print the remainder of the box.
Within this box, the pretty-printer emphasizes the box structure:
if a structural box does not fit fully on a simple line, a break
hint also splits the line if the splitting ``moves to the left''
(i.e. the new line gets an indentation smaller than the one of the current
line).
This box is the general purpose pretty-printing box.
If the pretty-printer splits the line in the box, offset [d] is added to
the current indentation.
*)valpp_close_box:formatter->unit->unit(** Closes the most recently open pretty-printing box. *)valpp_open_hbox:formatter->unit->unit(** [pp_open_hbox ppf ()] opens a new 'horizontal' pretty-printing box.
This box prints material on a single line.
Break hints in a horizontal box never split the line.
(Line splitting may still occur inside boxes nested deeper).
*)valpp_open_vbox:formatter->int->unit(** [pp_open_vbox ppf d] opens a new 'vertical' pretty-printing box
with offset [d].
This box prints material on as many lines as break hints in the box.
Every break hint in a vertical box splits the line.
If the pretty-printer splits the line in the box, [d] is added to the
current indentation.
*)valpp_open_hvbox:formatter->int->unit(** [pp_open_hvbox ppf d] opens a new 'horizontal/vertical' pretty-printing box
with offset [d].
This box behaves as an horizontal box if it fits on a single line,
otherwise it behaves as a vertical box.
If the pretty-printer splits the line in the box, [d] is added to the
current indentation.
*)valpp_open_hovbox:formatter->int->unit(** [pp_open_hovbox ppf d] opens a new 'horizontal-or-vertical'
pretty-printing box with offset [d].
This box prints material as much as possible on every line.
A break hint splits the line if there is no more room on the line to
print the remainder of the box.
If the pretty-printer splits the line in the box, [d] is added to the
current indentation.
*)(** {1 Formatting functions} *)valpp_print_string:formatter->string->unit(** [pp_print_string ppf s] prints [s] in the current pretty-printing box. *)valpp_print_as:formatter->int->string->unit(** [pp_print_as ppf len s] prints [s] in the current pretty-printing box.
The pretty-printer formats [s] as if it were of length [len].
*)valpp_print_int:formatter->int->unit(** Print an integer in the current pretty-printing box. *)valpp_print_char:formatter->char->unit(** Print a character in the current pretty-printing box. *)valpp_print_bool:formatter->bool->unit(** Print a boolean in the current pretty-printing box. *)(** {1:breaks Break hints} *)(** A 'break hint' tells the pretty-printer to output some space or split the
line whichever way is more appropriate to the current pretty-printing box
splitting rules.
Break hints are used to separate printing items and are mandatory to let
the pretty-printer correctly split lines and indent items.
Simple break hints are:
- the 'space': output a space or split the line if appropriate,
- the 'cut': split the line if appropriate.
Note: the notions of space and line splitting are abstract for the
pretty-printing engine, since those notions can be completely redefined
by the programmer.
However, in the pretty-printer default setting, ``output a space'' simply
means printing a space character (ASCII code 32) and ``split the line''
means printing a newline character (ASCII code 10).
*)valpp_print_space:formatter->unit->unit(** [pp_print_space ppf ()] emits a 'space' break hint:
the pretty-printer may split the line at this point,
otherwise it prints one space.
[pp_print_space ppf ()] is equivalent to [pp_print_break ppf 1 0].
*)valpp_print_cut:formatter->unit->unit(** [pp_print_cut ppf ()] emits a 'cut' break hint:
the pretty-printer may split the line at this point,
otherwise it prints nothing.
[pp_print_cut ppf ()] is equivalent to [pp_print_break ppf 0 0].
*)valpp_print_break:formatter->int->int->unit(** [pp_print_break ppf nspaces offset] emits a 'full' break hint:
the pretty-printer may split the line at this point,
otherwise it prints [nspaces] spaces.
If the pretty-printer splits the line, [offset] is added to
the current indentation.
*)valpp_print_custom_break:formatter->fits:(string*int*string)->breaks:(string*int*string)->unit(** [pp_print_custom_break ppf ~fits:(s1, n, s2) ~breaks:(s3, m, s4)] emits a
custom break hint: the pretty-printer may split the line at this point.
If it does not split the line, then the [s1] is emitted, then [n] spaces,
then [s2].
If it splits the line, then it emits the [s3] string, then an indent
(according to the box rules), then an offset of [m] spaces, then the [s4]
string.
While [n] and [m] are handled by [formatter_out_functions.out_indent], the
strings will be handled by [formatter_out_functions.out_string]. This allows
for a custom formatter that handles indentation distinctly, for example,
outputs [<br/>] tags or [ ] entities.
The custom break is useful if you want to change which visible
(non-whitespace) characters are printed in case of break or no break. For
example, when printing a list [ [a; b; c] ], you might want to add a
trailing semicolon when it is printed vertically:
{[
[
a;
b;
c;
]
]}
You can do this as follows:
{[
printf "@[<v 0>[@;<0 2>@[<v 0>a;@,b;@,c@]%t]@]@\n"
(pp_print_custom_break ~fits:("", 0, "") ~breaks:(";", 0, ""))
]}
@since 4.08.0
*)valpp_force_newline:formatter->unit->unit(** Force a new line in the current pretty-printing box.
The pretty-printer must split the line at this point,
Not the normal way of pretty-printing, since imperative line splitting may
interfere with current line counters and box size calculation.
Using break hints within an enclosing vertical box is a better
alternative.
*)valpp_print_if_newline:formatter->unit->unit(** Execute the next formatting command if the preceding line
has just been split. Otherwise, ignore the next formatting
command.
*)(** {1 Pretty-printing termination} *)valpp_print_flush:formatter->unit->unit(** End of pretty-printing: resets the pretty-printer to initial state.
All open pretty-printing boxes are closed, all pending text is printed.
In addition, the pretty-printer low level output device is flushed to
ensure that all pending text is really displayed.
Note: never use [print_flush] in the normal course of a pretty-printing
routine, since the pretty-printer uses a complex buffering machinery to
properly indent the output; manually flushing those buffers at random
would conflict with the pretty-printer strategy and result to poor
rendering.
Only consider using [print_flush] when displaying all pending material is
mandatory (for instance in case of interactive use when you want the user
to read some text) and when resetting the pretty-printer state will not
disturb further pretty-printing.
Warning: If the output device of the pretty-printer is an output channel,
repeated calls to [print_flush] means repeated calls to {!Stdlib.flush}
to flush the out channel; these explicit flush calls could foil the
buffering strategy of output channels and could dramatically impact
efficiency.
*)valpp_print_newline:formatter->unit->unit(** End of pretty-printing: resets the pretty-printer to initial state.
All open pretty-printing boxes are closed, all pending text is printed.
Equivalent to {!print_flush} followed by a new line.
See corresponding words of caution for {!print_flush}.
Note: this is not the normal way to output a new line;
the preferred method is using break hints within a vertical pretty-printing
box.
*)(** {1 Margin} *)valpp_set_margin:formatter->int->unit(** [pp_set_margin ppf d] sets the right margin to [d] (in characters):
the pretty-printer splits lines that overflow the right margin according to
the break hints given.
Setting the margin to [d] means that the formatting engine aims at
printing at most [d-1] characters per line.
Nothing happens if [d] is smaller than 2.
If [d] is too large, the right margin is set to the maximum
admissible value (which is greater than [10 ^ 9]).
If [d] is less than the current maximum indentation limit, the
maximum indentation limit is decreased while trying to preserve
a minimal ratio [max_indent/margin>=50%] and if possible
the current difference [margin - max_indent].
See also {!pp_set_geometry}.
*)valpp_get_margin:formatter->unit->int(** Returns the position of the right margin. *)(** {1:maxindent Maximum indentation limit} *)valpp_set_max_indent:formatter->int->unit(** [pp_set_max_indent ppf d] sets the maximum indentation limit of lines
to [d] (in characters):
once this limit is reached, new pretty-printing boxes are rejected to the
left, unless the enclosing box fully fits on the current line.
As an illustration,
{[ set_margin 10; set_max_indent 5; printf "@[123456@[7@]89A@]@." ]}
yields
{[
123456
789A
]}
because the nested box ["@[7@]"] is opened after the maximum indentation
limit ([7>5]) and its parent box does not fit on the current line.
Either decreasing the length of the parent box to make it fit on a line:
{[ printf "@[123456@[7@]89@]@." ]}
or opening an intermediary box before the maximum indentation limit which
fits on the current line
{[ printf "@[123@[456@[7@]89@]A@]@." ]}
avoids the rejection to the left of the inner boxes and print respectively
["123456789"] and ["123456789A"] .
Note also that vertical boxes never fit on a line whereas horizontal boxes
always fully fit on the current line.
Opening a box may split a line whereas the contents may have fit.
If this behavior is problematic, it can be curtailed by setting the maximum
indentation limit to [margin - 1]. Note that setting the maximum indentation
limit to [margin] is invalid.
Nothing happens if [d] is smaller than 2.
If [d] is too large, the limit is set to the maximum
admissible value (which is greater than [10 ^ 9]).
If [d] is greater or equal than the current margin, it is ignored,
and the current maximum indentation limit is kept.
See also {!pp_set_geometry}.
*)valpp_get_max_indent:formatter->unit->int(** Return the maximum indentation limit (in characters). *)(** {1 Maximum formatting depth} *)(** The maximum formatting depth is the maximum number of pretty-printing
boxes simultaneously open.
Material inside boxes nested deeper is printed as an ellipsis (more
precisely as the text returned by {!get_ellipsis_text} [()]).
*)valpp_set_max_boxes:formatter->int->unit(** [pp_set_max_boxes ppf max] sets the maximum number of pretty-printing
boxes simultaneously open.
Material inside boxes nested deeper is printed as an ellipsis (more
precisely as the text returned by {!get_ellipsis_text} [()]).
Nothing happens if [max] is smaller than 2.
*)valpp_get_max_boxes:formatter->unit->int(** Returns the maximum number of pretty-printing boxes allowed before
ellipsis.
*)valpp_over_max_boxes:formatter->unit->bool(** Tests if the maximum number of pretty-printing boxes allowed have already
been opened.
*)(** {1 Tabulation boxes} *)(**
A {e tabulation box} prints material on lines divided into cells of fixed
length. A tabulation box provides a simple way to display vertical columns
of left adjusted text.
This box features command [set_tab] to define cell boundaries, and command
[print_tab] to move from cell to cell and split the line when there is no
more cells to print on the line.
Note: printing within tabulation box is line directed, so arbitrary line
splitting inside a tabulation box leads to poor rendering. Yet, controlled
use of tabulation boxes allows simple printing of columns within
module {!Format}.
*)valpp_open_tbox:formatter->unit->unit(** [open_tbox ()] opens a new tabulation box.
This box prints lines separated into cells of fixed width.
Inside a tabulation box, special {e tabulation markers} defines points of
interest on the line (for instance to delimit cell boundaries).
Function {!Format.set_tab} sets a tabulation marker at insertion point.
A tabulation box features specific {e tabulation breaks} to move to next
tabulation marker or split the line. Function {!Format.print_tbreak} prints
a tabulation break.
*)valpp_close_tbox:formatter->unit->unit(** Closes the most recently opened tabulation box. *)valpp_set_tab:formatter->unit->unit(** Sets a tabulation marker at current insertion point. *)valpp_print_tab:formatter->unit->unit(** [print_tab ()] emits a 'next' tabulation break hint: if not already set on
a tabulation marker, the insertion point moves to the first tabulation
marker on the right, or the pretty-printer splits the line and insertion
point moves to the leftmost tabulation marker.
It is equivalent to [print_tbreak 0 0]. *)valpp_print_tbreak:formatter->int->int->unit(** [print_tbreak nspaces offset] emits a 'full' tabulation break hint.
If not already set on a tabulation marker, the insertion point moves to the
first tabulation marker on the right and the pretty-printer prints
[nspaces] spaces.
If there is no next tabulation marker on the right, the pretty-printer
splits the line at this point, then insertion point moves to the leftmost
tabulation marker of the box.
If the pretty-printer splits the line, [offset] is added to
the current indentation.
*)(** {1 Ellipsis} *)valpp_set_ellipsis_text:formatter->string->unit(** Set the text of the ellipsis printed when too many pretty-printing boxes
are open (a single dot, [.], by default).
*)valpp_get_ellipsis_text:formatter->unit->string(** Return the text of the ellipsis. *)(** {1 Convenience formatting functions.} *)valpp_print_list:?pp_sep:(formatter->unit->unit)->(formatter->'a->unit)->(formatter->'alist->unit)(** [pp_print_list ?pp_sep pp_v ppf l] prints items of list [l],
using [pp_v] to print each item, and calling [pp_sep]
between items ([pp_sep] defaults to {!pp_print_cut}.
Does nothing on empty lists.
@since 4.02.0
*)valpp_print_text:formatter->string->unit(** [pp_print_text ppf s] prints [s] with spaces and newlines respectively
printed using {!pp_print_space} and {!pp_force_newline}.
@since 4.02.0
*)valpp_print_option:?none:(formatter->unit->unit)->(formatter->'a->unit)->(formatter->'aoption->unit)(** [pp_print_option ?none pp_v ppf o] prints [o] on [ppf]
using [pp_v] if [o] is [Some v] and [none] if it is [None]. [none]
prints nothing by default.
@since 4.08 *)valpp_print_result:ok:(formatter->'a->unit)->error:(formatter->'e->unit)->formatter->('a,'e)result->unit(** [pp_print_result ~ok ~error ppf r] prints [r] on [ppf] using
[ok] if [r] is [Ok _] and [error] if [r] is [Error _].
@since 4.08 *)(** {1:fpp Formatted pretty-printing} *)(**
Module [Format] provides a complete set of [printf] like functions for
pretty-printing using format string specifications.
Specific annotations may be added in the format strings to give
pretty-printing commands to the pretty-printing engine.
Those annotations are introduced in the format strings using the [@]
character. For instance, [@ ] means a space break, [@,] means a cut,
[@\[] opens a new box, and [@\]] closes the last open box.
*)valfprintf:formatter->('a,formatter,unit)format->'a(** [fprintf ff fmt arg1 ... argN] formats the arguments [arg1] to [argN]
according to the format string [fmt], and outputs the resulting string on
the formatter [ff].
The format string [fmt] is a character string which contains three types of
objects: plain characters and conversion specifications as specified in
the {!Printf} module, and pretty-printing indications specific to the
[Format] module.
The pretty-printing indication characters are introduced by
a [@] character, and their meanings are:
- [@\[]: open a pretty-printing box. The type and offset of the
box may be optionally specified with the following syntax:
the [<] character, followed by an optional box type indication,
then an optional integer offset, and the closing [>] character.
Pretty-printing box type is one of [h], [v], [hv], [b], or [hov].
'[h]' stands for an 'horizontal' pretty-printing box,
'[v]' stands for a 'vertical' pretty-printing box,
'[hv]' stands for an 'horizontal/vertical' pretty-printing box,
'[b]' stands for an 'horizontal-or-vertical' pretty-printing box
demonstrating indentation,
'[hov]' stands a simple 'horizontal-or-vertical' pretty-printing box.
For instance, [@\[<hov 2>] opens an 'horizontal-or-vertical'
pretty-printing box with indentation 2 as obtained with [open_hovbox 2].
For more details about pretty-printing boxes, see the various box opening
functions [open_*box].
- [@\]]: close the most recently opened pretty-printing box.
- [@,]: output a 'cut' break hint, as with [print_cut ()].
- [@ ]: output a 'space' break hint, as with [print_space ()].
- [@;]: output a 'full' break hint as with [print_break]. The
[nspaces] and [offset] parameters of the break hint may be
optionally specified with the following syntax:
the [<] character, followed by an integer [nspaces] value,
then an integer [offset], and a closing [>] character.
If no parameters are provided, the good break defaults to a
'space' break hint.
- [@.]: flush the pretty-printer and split the line, as with
[print_newline ()].
- [@<n>]: print the following item as if it were of length [n].
Hence, [printf "@<0>%s" arg] prints [arg] as a zero length string.
If [@<n>] is not followed by a conversion specification,
then the following character of the format is printed as if
it were of length [n].
- [@\{]: open a semantic tag. The name of the tag may be optionally
specified with the following syntax:
the [<] character, followed by an optional string
specification, and the closing [>] character. The string
specification is any character string that does not contain the
closing character ['>']. If omitted, the tag name defaults to the
empty string.
For more details about semantic tags, see the functions {!open_stag} and
{!close_stag}.
- [@\}]: close the most recently opened semantic tag.
- [@?]: flush the pretty-printer as with [print_flush ()].
This is equivalent to the conversion [%!].
- [@\n]: force a newline, as with [force_newline ()], not the normal way
of pretty-printing, you should prefer using break hints inside a vertical
pretty-printing box.
Note: To prevent the interpretation of a [@] character as a
pretty-printing indication, escape it with a [%] character.
Old quotation mode [@@] is deprecated since it is not compatible with
formatted input interpretation of character ['@'].
Example: [printf "@[%s@ %d@]@." "x =" 1] is equivalent to
[open_box (); print_string "x ="; print_space ();
print_int 1; close_box (); print_newline ()].
It prints [x = 1] within a pretty-printing 'horizontal-or-vertical' box.
*)valsprintf:('a,unit,string)format->'a(** Same as [printf] above, but instead of printing on a formatter,
returns a string containing the result of formatting the arguments.
Note that the pretty-printer queue is flushed at the end of {e each
call} to [sprintf].
In case of multiple and related calls to [sprintf] to output
material on a single string, you should consider using [fprintf]
with the predefined formatter [str_formatter] and call
[flush_str_formatter ()] to get the final result.
Alternatively, you can use [Format.fprintf] with a formatter writing to a
buffer of your own: flushing the formatter and the buffer at the end of
pretty-printing returns the desired string.
*)valasprintf:('a,formatter,unit,string)format4->'a(** Same as [printf] above, but instead of printing on a formatter,
returns a string containing the result of formatting the arguments.
The type of [asprintf] is general enough to interact nicely with [%a]
conversions.
@since 4.01.0
*)valdprintf:('a,formatter,unit,formatter->unit)format4->'a(** Same as {!fprintf}, except the formatter is the last argument.
[dprintf "..." a b c] is a function of type
[formatter -> unit] which can be given to a format specifier [%t].
This can be used as a replacement for {!asprintf} to delay
formatting decisions. Using the string returned by {!asprintf} in a
formatting context forces formatting decisions to be taken in
isolation, and the final string may be created
prematurely. {!dprintf} allows delay of formatting decisions until
the final formatting context is known.
For example:
{[
let t = Format.dprintf "%i@ %i@ %i" 1 2 3 in
...
Format.printf "@[<v>%t@]" t
]}
@since 4.08.0
*)valifprintf:formatter->('a,formatter,unit)format->'a(** Same as [fprintf] above, but does not print anything.
Useful to ignore some material when conditionally printing.
@since 3.10.0
*)(** Formatted Pretty-Printing with continuations. *)valkfprintf:(formatter->'a)->formatter->('b,formatter,unit,'a)format4->'b(** Same as [fprintf] above, but instead of returning immediately,
passes the formatter to its first argument at the end of printing. *)valkdprintf:((formatter->unit)->'a)->('b,formatter,unit,'a)format4->'b(** Same as {!dprintf} above, but instead of returning immediately,
passes the suspended printer to its first argument at the end of printing.
@since 4.08.0
*)valikfprintf:(formatter->'a)->formatter->('b,formatter,unit,'a)format4->'b(** Same as [kfprintf] above, but does not print anything.
Useful to ignore some material when conditionally printing.
@since 3.12.0
*)valksprintf:(string->'a)->('b,unit,string,'a)format4->'b(** Same as [sprintf] above, but instead of returning the string,
passes it to the first argument. *)valkasprintf:(string->'a)->('b,formatter,unit,'a)format4->'b(** Same as [asprintf] above, but instead of returning the string,
passes it to the first argument.
@since 4.03
*)end# 22 "v8.in.ml"moduleLogging:sig# 1 "v8/logging.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2021 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Logging levels. See [docs/developer/guidelines.rst] for their meaning *)typelevel=Debug|Info|Notice|Warning|Error|Fatal(** Logs a message. It is the shell's responsibility to manage the actual
logging.
Even though logging may involve system calls, formatting, or other work, the
shell guarantees that calling this function doesn't transfer control over
another promise. Consequently, the performance of this function can be
considered predictable from the point of view of gas-consumption.
Note that the function call has predictable performance, but that it is the
caller's responsibility to ensure that argument evaluation has predictable
performance too. E.g., [log Notice "%s" (Format.asprint …)] may spend time
formatting the argument string. *)vallog:level->('a,Format.formatter,unit,unit)format4->'a(** Same as [log] but more efficient with a simpler interface. *)vallog_string:level->string->unitend# 24 "v8.in.ml"moduleHex:sig# 1 "v8/hex.mli"(*
* Copyright (c) 2015 Trevor Summers Smith <trevorsummerssmith@gmail.com>
* Copyright (c) 2014 Thomas Gazagnaire <thomas@gazagnaire.org>
*
* 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.
*)(** Hexadecimal encoding.
[Hex] defines hexadecimal encodings for {{!char}characters},
{{!string}strings} and {{!cstruct}Cstruct.t} buffers. *)typet=[`Hexofstring](** The type var hexadecimal values. *)(** {1:char Characters} *)valof_char:char->char*char(** [of_char c] is the the hexadecimal encoding of the character
[c]. *)valto_char:char->char->charoption(** [to_char x y] is the character corresponding to the [xy]
hexadecimal encoding.
Returns [None] if [x] or [y] are not in the ranges ['0'..'9'],
['a'..'f'], or ['A'..'F']. *)(** {1:string Strings} *)valof_string:?ignore:charlist->string->t(** [of_string s] is the hexadecimal representation of the binary
string [s]. If [ignore] is set, skip the characters in the list
when converting. Eg [of_string ~ignore:[' '] "a f"]. The default
value of [ignore] is [[]]). *)valto_string:t->stringoption(** [to_string t] is the binary string [s] such that [of_string s] is
[t].
Returns [None] if [t] contains a character that is not in the range ['0'..'9'],
['a'..'f'], or ['A'..'F']. *)(** {1:byte Bytes} *)valof_bytes:?ignore:charlist->bytes->t(** [of_bytes s] is the hexadecimal representation of the binary
string [s]. If [ignore] is set, skip the characters in the list
when converting. Eg [of_bytes ~ignore:[' '] "a f"]. The default
value of [ignore] is [[]]). *)valto_bytes:t->bytesoption(** [to_bytes t] is the binary string [s] such that [of_bytes s] is
[t].
Returns [None] if [t] contains a character that is not in the range ['0'..'9'],
['a'..'f'], or ['A'..'F']. *)(** {1 Debugging} *)valhexdump_s:?print_row_numbers:bool->?print_chars:bool->t->string(** Same as [hexdump] except returns a string. *)(** {1 Pretty printing} *)valpp:Format.formatter->t->unit[@@ocaml.toplevel_printer](** [pp fmt t] will output a human-readable hex representation of [t]
to the formatter [fmt]. *)valshow:t->string(** [show t] will return a human-readable hex representation of [t] as
a string. *)end# 26 "v8.in.ml"moduleZ:sig# 1 "v8/z.mli"(**
Integers.
This modules provides arbitrary-precision integers.
Small integers internally use a regular OCaml [int].
When numbers grow too large, we switch transparently to GMP numbers
([mpn] numbers fully allocated on the OCaml heap).
This interface is rather similar to that of [Int32] and [Int64],
with some additional functions provided natively by GMP
(GCD, square root, pop-count, etc.).
This file is part of the Zarith library
http://forge.ocamlcore.org/projects/zarith .
It is distributed under LGPL 2 licensing, with static linking exception.
See the LICENSE file included in the distribution.
Copyright (c) 2010-2011 Antoine Miné, Abstraction project.
Abstraction is part of the LIENS (Laboratoire d'Informatique de l'ENS),
a joint laboratory by:
CNRS (Centre national de la recherche scientifique, France),
ENS (École normale supérieure, Paris, France),
INRIA Rocquencourt (Institut national de recherche en informatique, France).
*)(** {1 Toplevel} *)(** For an optimal experience with the [ocaml] interactive toplevel,
the magic commands are:
{[
#load "zarith.cma";;
#install_printer Z.pp_print;;
]}
Alternatively, using the new [Zarith_top] toplevel module, simply:
{[
#require "zarith.top";;
]}
*)(** {1 Types} *)typet(** Type of integers of arbitrary length. *)exceptionOverflow(** Raised by conversion functions when the value cannot be represented in
the destination type.
*)(** {1 Construction} *)valzero:t(** The number 0. *)valone:t(** The number 1. *)valminus_one:t(** The number -1. *)externalof_int:int->t="%identity"(** Converts from a base integer. *)externalof_int32:int32->t="ml_z_of_int32"(** Converts from a 32-bit integer. *)externalof_int64:int64->t="ml_z_of_int64"(** Converts from a 64-bit integer. *)valof_string:string->t(** Converts a string to an integer.
An optional [-] prefix indicates a negative number, while a [+]
prefix is ignored.
An optional prefix [0x], [0o], or [0b] (following the optional [-]
or [+] prefix) indicates that the number is,
represented, in hexadecimal, octal, or binary, respectively.
Otherwise, base 10 is assumed.
(Unlike C, a lone [0] prefix does not denote octal.)
Raises an [Invalid_argument] exception if the string is not a
syntactically correct representation of an integer.
*)valof_substring:string->pos:int->len:int->t(** [of_substring s ~pos ~len] is the same as [of_string (String.sub s
pos len)]
*)valof_string_base:int->string->t(** Parses a number represented as a string in the specified base,
with optional [-] or [+] prefix.
The base must be between 2 and 16.
*)externalof_substring_base:int->string->pos:int->len:int->t="ml_z_of_substring_base"(** [of_substring_base base s ~pos ~len] is the same as [of_string_base
base (String.sub s pos len)]
*)(** {1 Basic arithmetic operations} *)valsucc:t->t(** Returns its argument plus one. *)valpred:t->t(** Returns its argument minus one. *)valabs:t->t(** Absolute value. *)valneg:t->t(** Unary negation. *)valadd:t->t->t(** Addition. *)valsub:t->t->t(** Subtraction. *)valmul:t->t->t(** Multiplication. *)valdiv:t->t->t(** Integer division. The result is truncated towards zero
and obeys the rule of signs.
Raises [Division_by_zero] if the divisor (second argument) is 0.
*)valrem:t->t->t(** Integer remainder. Can raise a [Division_by_zero].
The result of [rem a b] has the sign of [a], and its absolute value is
strictly smaller than the absolute value of [b].
The result satisfies the equality [a = b * div a b + rem a b].
*)externaldiv_rem:t->t->(t*t)="ml_z_div_rem"(** Computes both the integer quotient and the remainder.
[div_rem a b] is equal to [(div a b, rem a b)].
Raises [Division_by_zero] if [b = 0].
*)externalcdiv:t->t->t="ml_z_cdiv"(** Integer division with rounding towards +oo (ceiling).
Can raise a [Division_by_zero].
*)externalfdiv:t->t->t="ml_z_fdiv"(** Integer division with rounding towards -oo (floor).
Can raise a [Division_by_zero].
*)valediv_rem:t->t->(t*t)(** Euclidean division and remainder. [ediv_rem a b] returns a pair [(q, r)]
such that [a = b * q + r] and [0 <= r < |b|].
Raises [Division_by_zero] if [b = 0].
*)valediv:t->t->t(** Euclidean division. [ediv a b] is equal to [fst (ediv_rem a b)].
The result satisfies [0 <= a - b * ediv a b < |b|].
Raises [Division_by_zero] if [b = 0].
*)valerem:t->t->t(** Euclidean remainder. [erem a b] is equal to [snd (ediv_rem a b)].
The result satisfies [0 <= erem a b < |b|] and
[a = b * ediv a b + erem a b]. Raises [Division_by_zero] if [b = 0].
*)valdivexact:t->t->t(** [divexact a b] divides [a] by [b], only producing correct result when the
division is exact, i.e., when [b] evenly divides [a].
It should be faster than general division.
Can raise a [Division_by_zero].
*)externaldivisible:t->t->bool="ml_z_divisible"(** [divisible a b] returns [true] if [a] is exactly divisible by [b].
Unlike the other division functions, [b = 0] is accepted
(only 0 is considered divisible by 0).
*)externalcongruent:t->t->t->bool="ml_z_congruent"(** [congruent a b c] returns [true] if [a] is congruent to [b] modulo [c].
Unlike the other division functions, [c = 0] is accepted
(only equal numbers are considered equal congruent 0).
*)(** {1 Bit-level operations} *)(** For all bit-level operations, negative numbers are considered in 2's
complement representation, starting with a virtual infinite number of
1s.
*)vallogand:t->t->t(** Bitwise logical and. *)vallogor:t->t->t(** Bitwise logical or. *)vallogxor:t->t->t(** Bitwise logical exclusive or. *)vallognot:t->t(** Bitwise logical negation.
The identity [lognot a]=[-a-1] always hold.
*)valshift_left:t->int->t(** Shifts to the left.
Equivalent to a multiplication by a power of 2.
The second argument must be nonnegative.
*)valshift_right:t->int->t(** Shifts to the right.
This is an arithmetic shift,
equivalent to a division by a power of 2 with rounding towards -oo.
The second argument must be nonnegative.
*)valshift_right_trunc:t->int->t(** Shifts to the right, rounding towards 0.
This is equivalent to a division by a power of 2, with truncation.
The second argument must be nonnegative.
*)externalnumbits:t->int="ml_z_numbits"[@@noalloc](** Returns the number of significant bits in the given number.
If [x] is zero, [numbits x] returns 0. Otherwise,
[numbits x] returns a positive integer [n] such that
[2^{n-1} <= |x| < 2^n]. Note that [numbits] is defined
for negative arguments, and that [numbits (-x) = numbits x]. *)externaltrailing_zeros:t->int="ml_z_trailing_zeros"[@@noalloc](** Returns the number of trailing 0 bits in the given number.
If [x] is zero, [trailing_zeros x] returns [max_int].
Otherwise, [trailing_zeros x] returns a nonnegative integer [n]
which is the largest [n] such that [2^n] divides [x] evenly.
Note that [trailing_zeros] is defined for negative arguments,
and that [trailing_zeros (-x) = trailing_zeros x]. *)valtestbit:t->int->bool(** [testbit x n] return the value of bit number [n] in [x]:
[true] if the bit is 1, [false] if the bit is 0.
Bits are numbered from 0. Raise [Invalid_argument] if [n]
is negative. *)externalpopcount:t->int="ml_z_popcount"(** Counts the number of bits set.
Raises [Overflow] for negative arguments, as those have an infinite
number of bits set.
*)externalhamdist:t->t->int="ml_z_hamdist"(** Counts the number of different bits.
Raises [Overflow] if the arguments have different signs
(in which case the distance is infinite).
*)(** {1 Conversions} *)(** Note that, when converting to an integer type that cannot represent the
converted value, an [Overflow] exception is raised.
*)valto_int:t->int(** Converts to a base integer. May raise an [Overflow]. *)externalto_int32:t->int32="ml_z_to_int32"(** Converts to a 32-bit integer. May raise [Overflow]. *)externalto_int64:t->int64="ml_z_to_int64"(** Converts to a 64-bit integer. May raise [Overflow]. *)valto_string:t->string(** Gives a human-readable, decimal string representation of the argument. *)externalformat:string->t->string="ml_z_format"(** Gives a string representation of the argument in the specified
printf-like format.
The general specification has the following form:
[% \[flags\] \[width\] type]
Where the type actually indicates the base:
- [i], [d], [u]: decimal
- [b]: binary
- [o]: octal
- [x]: lowercase hexadecimal
- [X]: uppercase hexadecimal
Supported flags are:
- [+]: prefix positive numbers with a [+] sign
- space: prefix positive numbers with a space
- [-]: left-justify (default is right justification)
- [0]: pad with zeroes (instead of spaces)
- [#]: alternate formatting (actually, simply output a literal-like prefix: [0x], [0b], [0o])
Unlike the classic [printf], all numbers are signed (even hexadecimal ones),
there is no precision field, and characters that are not part of the format
are simply ignored (and not copied in the output).
*)externalfits_int:t->bool="ml_z_fits_int"[@@noalloc](** Whether the argument fits in a regular [int]. *)externalfits_int32:t->bool="ml_z_fits_int32"[@@noalloc](** Whether the argument fits in an [int32]. *)externalfits_int64:t->bool="ml_z_fits_int64"[@@noalloc](** Whether the argument fits in an [int64]. *)(** {1 Printing} *)valpp_print:Format.formatter->t->unit(** Prints the argument on the specified formatter.
Can be used as [%a] format printer in [Format.printf] and as
argument to [#install_printer] in the top-level.
*)(** {1 Ordering} *)externalcompare:t->t->int="ml_z_compare"[@@noalloc](** Comparison. [compare x y] returns 0 if [x] equals [y],
-1 if [x] is smaller than [y], and 1 if [x] is greater than [y].
Note that Pervasive.compare can be used to compare reliably two integers
only on OCaml 3.12.1 and later versions.
*)externalequal:t->t->bool="ml_z_equal"[@@noalloc](** Equality test. *)valleq:t->t->bool(** Less than or equal. *)valgeq:t->t->bool(** Greater than or equal. *)vallt:t->t->bool(** Less than (and not equal). *)valgt:t->t->bool(** Greater than (and not equal). *)externalsign:t->int="ml_z_sign"[@@noalloc](** Returns -1, 0, or 1 when the argument is respectively negative, null, or
positive.
*)valmin:t->t->t(** Returns the minimum of its arguments. *)valmax:t->t->t(** Returns the maximum of its arguments. *)valis_even:t->bool(** Returns true if the argument is even (divisible by 2), false if odd. *)valis_odd:t->bool(** Returns true if the argument is odd, false if even. *)(** {1 Powers} *)externalpow:t->int->t="ml_z_pow"(** [pow base exp] raises [base] to the [exp] power.
[exp] must be nonnegative.
Note that only exponents fitting in a machine integer are supported, as
larger exponents would surely make the result's size overflow the
address space.
*)externalsqrt:t->t="ml_z_sqrt"(** Returns the square root. The result is truncated (rounded down
to an integer).
Raises an [Invalid_argument] on negative arguments.
*)externalsqrt_rem:t->(t*t)="ml_z_sqrt_rem"(** Returns the square root truncated, and the remainder.
Raises an [Invalid_argument] on negative arguments.
*)externalroot:t->int->t="ml_z_root"(** [root x n] computes the [n]-th root of [x].
[n] must be positive and, if [n] is even, then [x] must be nonnegative.
Otherwise, an [Invalid_argument] is raised.
*)externalrootrem:t->int->t*t="ml_z_rootrem"(** [rootrem x n] computes the [n]-th root of [x] and the remainder
[x-root**n].
[n] must be positive and, if [n] is even, then [x] must be nonnegative.
Otherwise, an [Invalid_argument] is raised.
*)externalperfect_power:t->bool="ml_z_perfect_power"(** True if the argument has the form [a^b], with [b>1] *)externalperfect_square:t->bool="ml_z_perfect_square"(** True if the argument has the form [a^2]. *)vallog2:t->int(** Returns the base-2 logarithm of its argument, rounded down to
an integer. If [x] is positive, [log2 x] returns the largest [n]
such that [2^n <= x]. If [x] is negative or zero, [log2 x] raise
the [Invalid_argument] exception. *)vallog2up:t->int(** Returns the base-2 logarithm of its argument, rounded up to
an integer. If [x] is positive, [log2up x] returns the smallest [n]
such that [x <= 2^n]. If [x] is negative or zero, [log2up x] raise
the [Invalid_argument] exception. *)(** {1 Representation} *)externalsize:t->int="ml_z_size"[@@noalloc](** Returns the number of machine words used to represent the number. *)externalextract:t->int->int->t="ml_z_extract"(** [extract a off len] returns a nonnegative number corresponding to bits
[off] to [off]+[len]-1 of [b].
Negative [a] are considered in infinite-length 2's complement
representation.
*)valsigned_extract:t->int->int->t(** [signed_extract a off len] extracts bits [off] to [off]+[len]-1 of [b],
as [extract] does, then sign-extends bit [len-1] of the result
(that is, bit [off + len - 1] of [a]). The result is between
[- 2{^[len]-1}] (included) and [2{^[len]-1}] (excluded),
and equal to [extract a off len] modulo [2{^len}].
*)externalto_bits:t->string="ml_z_to_bits"(** Returns a binary representation of the argument.
The string result should be interpreted as a sequence of bytes,
corresponding to the binary representation of the absolute value of
the argument in little endian ordering.
The sign is not stored in the string.
*)externalof_bits:string->t="ml_z_of_bits"(** Constructs a number from a binary string representation.
The string is interpreted as a sequence of bytes in little endian order,
and the result is always positive.
We have the identity: [of_bits (to_bits x) = abs x].
However, we can have [to_bits (of_bits s) <> s] due to the presence of
trailing zeros in s.
*)end# 28 "v8.in.ml"moduleQ:sig# 1 "v8/q.mli"(**
Rationals.
This modules builds arbitrary precision rationals on top of arbitrary
integers from module Z.
This file is part of the Zarith library
http://forge.ocamlcore.org/projects/zarith .
It is distributed under LGPL 2 licensing, with static linking exception.
See the LICENSE file included in the distribution.
Copyright (c) 2010-2011 Antoine Miné, Abstraction project.
Abstraction is part of the LIENS (Laboratoire d'Informatique de l'ENS),
a joint laboratory by:
CNRS (Centre national de la recherche scientifique, France),
ENS (École normale supérieure, Paris, France),
INRIA Rocquencourt (Institut national de recherche en informatique, France).
*)(** {1 Types} *)typet={num:Z.t;(** Numerator. *)den:Z.t;(** Denominator, >= 0 *)}(** A rational is represented as a pair numerator/denominator, reduced to
have a non-negative denominator and no common factor.
This form is canonical (enabling polymorphic equality and hashing).
The representation allows three special numbers: [inf] (1/0), [-inf] (-1/0)
and [undef] (0/0).
*)(** {1 Construction} *)valmake:Z.t->Z.t->t(** [make num den] constructs a new rational equal to [num]/[den].
It takes care of putting the rational in canonical form.
*)valzero:tvalone:tvalminus_one:t(** 0, 1, -1. *)valinf:t(** 1/0. *)valminus_inf:t(** -1/0. *)valundef:t(** 0/0. *)valof_bigint:Z.t->tvalof_int:int->tvalof_int32:int32->tvalof_int64:int64->t(** Conversions from various integer types. *)valof_ints:int->int->t(** Conversion from an [int] numerator and an [int] denominator. *)valof_string:string->t(** Converts a string to a rational. Plain integers, [/] separated
integer ratios (with optional sign), decimal point and scientific
notations are understood.
Additionally, the special [inf], [-inf], and [undef] are
recognized (they can also be typeset respectively as [1/0], [-1/0],
[0/0]). *)(** {1 Inspection} *)valnum:t->Z.t(** Get the numerator. *)valden:t->Z.t(** Get the denominator. *)(** {1 Testing} *)typekind=|ZERO(** 0 *)|INF(** infinity, i.e. 1/0 *)|MINF(** minus infinity, i.e. -1/0 *)|UNDEF(** undefined, i.e., 0/0 *)|NZERO(** well-defined, non-infinity, non-zero number *)(** Rationals can be categorized into different kinds, depending mainly on
whether the numerator and/or denominator is null.
*)valclassify:t->kind(** Determines the kind of a rational. *)valis_real:t->bool(** Whether the argument is non-infinity and non-undefined. *)valsign:t->int(** Returns 1 if the argument is positive (including inf), -1 if it is
negative (including -inf), and 0 if it is null or undefined.
*)valcompare:t->t->int(** [compare x y] compares [x] to [y] and returns 1 if [x] is strictly
greater that [y], -1 if it is strictly smaller, and 0 if they are
equal.
This is a total ordering.
Infinities are ordered in the natural way, while undefined is considered
the smallest of all: undef = undef < -inf <= -inf < x < inf <= inf.
This is consistent with OCaml's handling of floating-point infinities
and NaN.
OCaml's polymorphic comparison will NOT return a result consistent with
the ordering of rationals.
*)valequal:t->t->bool(** Equality testing.
Unlike [compare], this follows IEEE semantics: [undef] <> [undef].
*)valmin:t->t->t(** Returns the smallest of its arguments. *)valmax:t->t->t(** Returns the largest of its arguments. *)valleq:t->t->bool(** Less than or equal. [leq undef undef] resturns false. *)valgeq:t->t->bool(** Greater than or equal. [leq undef undef] resturns false. *)vallt:t->t->bool(** Less than (not equal). *)valgt:t->t->bool(** Greater than (not equal). *)(** {1 Conversions} *)valto_bigint:t->Z.tvalto_int:t->intvalto_int32:t->int32valto_int64:t->int64(** Convert to integer by truncation.
Raises a [Divide_by_zero] if the argument is an infinity or undefined.
Raises a [Z.Overflow] if the result does not fit in the destination
type.
*)valto_string:t->string(** Converts to human-readable, base-10, [/]-separated rational. *)(** {1 Arithmetic operations} *)(**
In all operations, the result is [undef] if one argument is [undef].
Other operations can return [undef]: such as [inf]-[inf], [inf]*0, 0/0.
*)valneg:t->t(** Negation. *)valabs:t->t(** Absolute value. *)valadd:t->t->t(** Addition. *)valsub:t->t->t(** Subtraction. We have [sub x y] = [add x (neg y)]. *)valmul:t->t->t(** Multiplication. *)valinv:t->t(** Inverse.
Note that [inv 0] is defined, and equals [inf].
*)valdiv:t->t->t(** Division.
We have [div x y] = [mul x (inv y)], and [inv x] = [div one x].
*)valmul_2exp:t->int->t(** [mul_2exp x n] multiplies [x] by 2 to the power of [n]. *)valdiv_2exp:t->int->t(** [div_2exp x n] divides [x] by 2 to the power of [n]. *)(** {1 Printing} *)valpp_print:Format.formatter->t->unit(** Prints the argument on the specified formatter.
Also intended to be used as [%a] format printer in [Format.printf].
*)(** {1 Prefix and infix operators} *)(**
Classic prefix and infix [int] operators are redefined on [t].
*)val(~-):t->t(** Negation [neg]. *)val(~+):t->t(** Identity. *)val(+):t->t->t(** Addition [add]. *)val(-):t->t->t(** Subtraction [sub]. *)val(*):t->t->t(** Multiplication [mul]. *)val(/):t->t->t(** Division [div]. *)val(lsl):t->int->t(** Multiplication by a power of two [mul_2exp]. *)val(asr):t->int->t(** Division by a power of two [shift_right]. *)val(~$):int->t(** Conversion from [int]. *)val(//):int->int->t(** Creates a rational from two [int]s. *)val(~$$):Z.t->t(** Conversion from [Z.t]. *)val(///):Z.t->Z.t->t(** Creates a rational from two [Z.t]. *)val(=):t->t->bool(** Same as [equal]. *)val(<):t->t->bool(** Same as [lt]. *)val(>):t->t->bool(** Same as [gt]. *)val(<=):t->t->bool(** Same as [leq]. *)val(>=):t->t->bool(** Same as [geq]. *)val(<>):t->t->bool(** [a <> b] is equivalent to [not (equal a b)]. *)end# 30 "v8.in.ml"moduleLwt:sig# 1 "v8/lwt.mli"(* This file is part of Lwt, released under the MIT license. See LICENSE.md for
details, or visit https://github.com/ocsigen/lwt/blob/master/LICENSE.md. *)(** {2 Fundamentals} *)(** {3 Promises} *)type+'at(** Promises for values of type ['a].
A {b promise} is a memory cell that is always in one of three {b states}:
- {e fulfilled}, and containing one value of type ['a],
- {e rejected}, and containing one exception, or
- {e pending}, in which case it may become fulfilled or rejected later.
A {e resolved} promise is one that is either fulfilled or rejected, i.e. not
pending. Once a promise is resolved, its content cannot change. So, promises
are {e write-once references}. The only possible state changes are (1) from
pending to fulfilled and (2) from pending to rejected.
Promises are typically “read” by attaching {b callbacks} to them. The most
basic functions for that are {!Lwt.bind}, which attaches a callback that is
called when a promise becomes fulfilled, and {!Lwt.catch}, for rejection.
Promise variables of this type, ['a Lwt.t], are actually {b read-only} in
Lwt. Separate {e resolvers} of type ['a ]{!Lwt.u} are used to write to them.
Promises and their resolvers are created together by calling {!Lwt.wait}.
There is one exception to this: most promises can be {e canceled} by calling
{!Lwt.cancel}, without going through a resolver. *)(** We omit [u], [wait], [wakeup*] and so on because these are only useful to
define new synchronization primitives which the protocol doesn't need: it
gets its synchronization primitives from the environment. *)valreturn:'a->'at(** [Lwt.return v] creates a new {{: #TYPEt} promise} that is {e already
fulfilled} with value [v].
This is needed to satisfy the type system in some cases. For example, in a
[match] expression where one case evaluates to a promise, the other cases
have to evaluate to promises as well:
{[
match need_input with
| true -> Lwt_io.(read_line stdin) (* Has type string Lwt.t... *)
| false -> Lwt.return "" (* ...so wrap empty string in a promise. *)
]}
Another typical usage is in {{: #VALbind} [let%lwt]}. The expression after
the “[in]” has to evaluate to a promise. So, if you compute an ordinary
value instead, you have to wrap it:
{[
let%lwt line = Lwt_io.(read_line stdin) in
Lwt.return (line ^ ".")
]} *)(** We omit [fail] as well as [catch] and such because we discourage the use of
exceptions in the environment. The Error Monad provides sufficient
primitives. *)(** {3 Callbacks} *)valbind:'at->('a->'bt)->'bt(** [Lwt.bind p_1 f] makes it so that [f] will run when [p_1] is {{: #TYPEt}
{e fulfilled}}.
When [p_1] is fulfilled with value [v_1], the callback [f] is called with
that same value [v_1]. Eventually, after perhaps starting some I/O or other
computation, [f] returns promise [p_2].
[Lwt.bind] itself returns immediately. It only attaches the callback [f] to
[p_1] – it does not wait for [p_2]. {e What} [Lwt.bind] returns is yet a
third promise, [p_3]. Roughly speaking, fulfillment of [p_3] represents both
[p_1] and [p_2] becoming fulfilled, one after the other.
A minimal example of this is an echo program:
{[
let () =
let p_3 =
Lwt.bind
Lwt_io.(read_line stdin)
(fun line -> Lwt_io.printl line)
in
Lwt_main.run p_3
(* ocamlfind opt -linkpkg -thread -package lwt.unix code.ml && ./a.out *)
]}
Rejection of [p_1] and [p_2], and raising an exception in [f], are all
forwarded to rejection of [p_3].
{b Precise behavior}
[Lwt.bind] returns a promise [p_3] immediately. [p_3] starts out pending,
and is resolved as follows:
- The first condition to wait for is that [p_1] becomes resolved. It does
not matter whether [p_1] is already resolved when [Lwt.bind] is called, or
becomes resolved later – the rest of the behavior is the same.
- If and when [p_1] becomes resolved, it will, by definition, be either
fulfilled or rejected.
- If [p_1] is rejected, [p_3] is rejected with the same exception.
- If [p_1] is fulfilled, with value [v], [f] is applied to [v].
- [f] may finish by returning the promise [p_2], or raising an exception.
- If [f] raises an exception, [p_3] is rejected with that exception.
- Finally, the remaining case is when [f] returns [p_2]. From that point on,
[p_3] is effectively made into a reference to [p_2]. This means they have
the same state, undergo the same state changes, and performing any
operation on one is equivalent to performing it on the other.
{b Syntactic sugar}
[Lwt.bind] is almost never written directly, because sequences of [Lwt.bind]
result in growing indentation and many parentheses:
{[
let () =
Lwt_main.run begin
Lwt.bind Lwt_io.(read_line stdin) (fun line ->
Lwt.bind (Lwt_unix.sleep 1.) (fun () ->
Lwt_io.printf "One second ago, you entered %s\n" line))
end
(* ocamlfind opt -linkpkg -thread -package lwt.unix code.ml && ./a.out *)
]}
The recommended way to write [Lwt.bind] is using the [let%lwt] syntactic
sugar:
{[
let () =
Lwt_main.run begin
let%lwt line = Lwt_io.(read_line stdin) in
let%lwt () = Lwt_unix.sleep 1. in
Lwt_io.printf "One second ago, you entered %s\n" line
end
(* ocamlfind opt -linkpkg -thread -package lwt_ppx,lwt.unix code.ml && ./a.out *)
]}
This uses the Lwt {{: Ppx_lwt.html} PPX} (preprocessor). Note that we had to
add package [lwt_ppx] to the command line for building this program. We will
do that throughout this manual.
Another way to write [Lwt.bind], that you may encounter while reading code,
is with the [>>=] operator:
{[
open Lwt.Infix
let () =
Lwt_main.run begin
Lwt_io.(read_line stdin) >>= fun line ->
Lwt_unix.sleep 1. >>= fun () ->
Lwt_io.printf "One second ago, you entered %s\n" line
end
(* ocamlfind opt -linkpkg -thread -package lwt.unix code.ml && ./a.out *)
]}
The [>>=] operator comes from the module {!Lwt.Infix}, which is why we
opened it at the beginning of the program.
See also {!Lwt.map}. *)(** We omit [dont_wait] and other such functions because they are only useful
in mutation-heavy loosely-synchronised code which the protocol shouldn't be.
*)(** We omit many synchronisation primitives such as [choose] because they
introduce non-determinism. *)(** We omit cancelation-related primitives because we discourage Cancelation in
the protocol. *)(** {2 Convenience} *)(** {3 Callback helpers} *)valmap:('a->'b)->'at->'bt(** [Lwt.map f p_1] is similar to {!Lwt.bind}[ p_1 f], but [f] is not expected
to return a promise.
This function is more convenient that {!Lwt.bind} when [f] inherently does
not return a promise. An example is [Stdlib.int_of_string]:
{[
let read_int : unit -> int Lwt.t = fun () ->
Lwt.map
int_of_string
Lwt_io.(read_line stdin)
let () =
Lwt_main.run begin
let%lwt number = read_int () in
Lwt_io.printf "%i\n" number
end
(* ocamlfind opt -linkpkg -thread -package lwt_ppx,lwt.unix code.ml && ./a.out *)
]}
By comparison, the {!Lwt.bind} version is more awkward:
{[
let read_int : unit -> int Lwt.t = fun () ->
Lwt.bind
Lwt_io.(read_line stdin)
(fun line -> Lwt.return (int_of_string line))
]}
As with {!Lwt.bind}, sequences of calls to [Lwt.map] result in excessive
indentation and parentheses. The recommended syntactic sugar for avoiding
this is the {{: #VAL(>|=)} [>|=]} operator, which comes from module
[Lwt.Infix]:
{[
open Lwt.Infix
let read_int : unit -> int Lwt.t = fun () ->
Lwt_io.(read_line stdin) >|= int_of_string
]}
The detailed operation follows. For consistency with the promises in
{!Lwt.bind}, the {e two} promises involved are named [p_1] and [p_3]:
- [p_1] is the promise passed to [Lwt.map].
- [p_3] is the promise returned by [Lwt.map].
[Lwt.map] returns a promise [p_3]. [p_3] starts out pending. It is resolved
as follows:
- [p_1] may be, or become, resolved. In that case, by definition, it will
become fulfilled or rejected. Fulfillment is the interesting case, but the
behavior on rejection is simpler, so we focus on rejection first.
- When [p_1] becomes rejected, [p_3] is rejected with the same exception.
- When [p_1] instead becomes fulfilled, call the value it is fulfilled with
[v].
- [f v] is applied. If this finishes, it may either return another value, or
raise an exception.
- If [f v] returns another value [v'], [p_3] is fulfilled with [v'].
- If [f v] raises exception [exn], [p_3] is rejected with [exn]. *)(** We omit explicit callback registration ([on_termination] and such) because
it is only useful for mutation-heavy code *)(** We omit syntax helpers because they are available through the dedicated
syntax modules of the Error Monad. *)(** {3 Pre-allocated promises} *)valreturn_unit:unitt(** [Lwt.return_unit] is defined as {!Lwt.return}[ ()], but this definition is
evaluated only once, during initialization of module [Lwt], at the beginning
of your program.
This means the promise is allocated only once. By contrast, each time
{!Lwt.return}[ ()] is evaluated, it allocates a new promise.
It is recommended to use [Lwt.return_unit] only where you know the
allocations caused by an instance of {!Lwt.return}[ ()] are a performance
bottleneck. Generally, the cost of I/O tends to dominate the cost of
{!Lwt.return}[ ()] anyway.
In future Lwt, we hope to perform this optimization, of using a single,
pre-allocated promise, automatically, wherever {!Lwt.return}[ ()] is
written. *)valreturn_none:(_option)t(** [Lwt.return_none] is like {!Lwt.return_unit}, but for
{!Lwt.return}[ None]. *)valreturn_nil:(_list)t(** [Lwt.return_nil] is like {!Lwt.return_unit}, but for {!Lwt.return}[ []]. *)valreturn_true:boolt(** [Lwt.return_true] is like {!Lwt.return_unit}, but for
{!Lwt.return}[ true]. *)valreturn_false:boolt(** [Lwt.return_false] is like {!Lwt.return_unit}, but for
{!Lwt.return}[ false]. *)(** We omit state introspection because it is discouraged when not defining new
synchronisation primitives which the protocol doesn't do. *)valreturn_some:'a->('aoption)t(** Counterpart to {!Lwt.return_none}. However, unlike {!Lwt.return_none}, this
function performs no {{: #VALreturn_unit} optimization}. This is because it
takes an argument, so it cannot be evaluated at initialization time, at
which time the argument is not yet available. *)valreturn_ok:'a->(('a,_)result)t(** Like {!Lwt.return_some}, this function performs no optimization.
@since Lwt 2.6.0 *)valreturn_error:'e->((_,'e)result)t(** Like {!Lwt.return_some}, this function performs no optimization.
@since Lwt 2.6.0 *)end# 32 "v8.in.ml"moduleData_encoding:sig# 1 "v8/data_encoding.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** In memory JSON data *)typejson=[`Oof(string*json)list|`Boolofbool|`Floatoffloat|`Aofjsonlist|`Null|`Stringofstring](* [tag_size] is not declared in the upstream library, instead, the expanded
polymorphic-variant type-expression is used as is. We include it in the
protocol environment to help coq-of-ocaml process the files. *)typetag_size=[`Uint8|`Uint16]typejson_schema(** The type descriptors for values of type ['a]. *)type'attype'aencoding='attypestring_json_repr=Hex|Plainvalclassify:'aencoding->[`Fixedofint|`Dynamic|`Variable](** {3 Ground descriptors} *)(** {4 voids} *)(** Special value [null] in JSON, nothing in binary. *)valnull:unitencoding(** Empty object (not included in binary, encoded as empty object in JSON). *)valempty:unitencoding(** Unit value, omitted in binary.
Serialized as an empty object in JSON, accepts any object when deserializing. *)valunit:unitencoding(** Constant string (data is not included in the binary data). *)valconstant:string->unitencoding(** {4 ground numerical types}
All encodings are big-endians.
- 8-bit integers (signed or unsigned) are encoded over 1 single byte.
- 16-bit integers (signed or unsigned) are encoded over 2 bytes.
- 31-bit integers are always signed and always encoded over 4 bytes.
- 32-bit integers are always signed and always encoded over 4 bytes.
- 64-bit integers are always signed and always encoded over 8 bytes.
A note on 31-bit integers. The internal representation of integers in
OCaml reserves one bit for GC tagging. The remaining bits encode a signed
integer. For compatibility with 32-bit machine, we restrict these native
integers to the 31-bit range. *)(** Signed 8 bit integer
(data is encoded as a byte in binary and an integer in JSON). *)valint8:intencoding(** Unsigned 8 bit integer
(data is encoded as a byte in binary and an integer in JSON). *)valuint8:intencoding(** Signed 16 bit integer
(data is encoded as a short in binary and an integer in JSON). *)valint16:intencoding(** Unsigned 16 bit integer
(data is encoded as a short in binary and an integer in JSON). *)valuint16:intencoding(** Signed 31 bit integer, which corresponds to type int on 32-bit OCaml systems
(data is encoded as a 32 bit int in binary and an integer in JSON). *)valint31:intencoding(** Signed 32 bit integer
(data is encoded as a 32-bit int in binary and an integer in JSON). *)valint32:int32encoding(** Signed 64 bit integer
(data is encoded as a 64-bit int in binary and a decimal string in JSON). *)valint64:int64encoding(** Integer with bounds in a given range. Both bounds are inclusive.
@raise Invalid_argument if the bounds are beyond the interval
[-2^30; 2^30-1]. These bounds are chosen to be compatible with all versions
of OCaml.
*)valranged_int:int->int->intencoding(** Big number
In JSON, data is encoded as a decimal string.
In binary, data is encoded as a variable length sequence of
bytes, with a running unary size bit: the most significant bit of
each byte tells is this is the last byte in the sequence (0) or if
there is more to read (1). The second most significant bit of the
first byte is reserved for the sign (positive if zero). Binary_size and
sign bits ignored, data is then the binary representation of the
absolute value of the number in little-endian order. *)valz:Z.tencoding(** Positive big number, see [z]. *)valn:Z.tencoding(** [uint_like_n ()] is an encoding for [int] which uses the same representation
as {!n}.
For compatibility with 32-bit machines, this encoding supports the same
range of encodings as [int31], but only the positive ones. I.e., it
supports the inclusive range [0] to [(1 lsl 30) - 1].
The optional parameter [?max_value] can be used to further restrict the
range of values. If [max_value] is set and is greater than
[(1 lsl 30) - 1] then the function raises [Invalid_argument].
The encoding is partial: attempting to de/serialise values which are
outside of the supported range will fail. In addition, in binary, a
maximum size for the serialised representation is computed based on the
maximum value in the range, and the de/serialisation process fails before
attempting any conversion if the size is exceeded.
@raise Invalid_argument if [max_value < 0] or
[max_value > (1 lsl 30) - 1] *)valuint_like_n:?max_value:int->unit->intencoding(** [int_like_z ()] is an encoding for [int] which uses the same representation
as {!z}.
For compatibility with 32-bit machines, this encoding supports the same
range of encodings as [int31]. I.e., it supports the inclusive range
[-(1 lsl 30)] to [(1 lsl 30) - 1].
The optional parameters [?min_value] and [?max_value] can be used to
further restrict the
range of values. If [min_value] is set and less than [-(1 lsl 30)] or if
[max_value] is set and is greater than [(1 lsl 30) - 1] then the function
raises [Invalid_argument].
The encoding is partial: attempting to de/serialise values which are
outside of the supported range will fail. In addition, in binary, a
maximum size for the serialised representation is computed based on the
encoding's range, and the de/serialisation process fails before attempting
any conversion if the size is exceeded.
@raise Invalid_argument if [max_value < min_value]
@raise Invalid_argument if [max_value > (1 lsl 30) - 1]
@raise Invalid_argument if [min_value < -(1 lsl 30)] *)valint_like_z:?min_value:int->?max_value:int->unit->intencoding(** {4 Other ground type encodings} *)(** Encoding of a boolean
(data is encoded as a byte in binary and a boolean in JSON). *)valbool:boolencoding(** Encoding of a string
- In binary, encoded as a byte sequence prefixed by the length
of the string. The length is represented as specified by the
[length_kind] parameter (default [`Uint30]).
- in JSON when [string_json_repr = Plain], encoded as a string
- in JSON when [string_json_repr = Hex], encoded via hex. *)valstring:?length_kind:[`N|`Uint30|`Uint16|`Uint8]->string_json_repr->stringencoding(** Encoding of arbitrary bytes. See [string] *)valbytes:?length_kind:[`N|`Uint30|`Uint16|`Uint8]->string_json_repr->Bytes.tencoding(** {3 Descriptor combinators} *)(** Combinator to make an optional value
(represented as a 1-byte tag followed by the data (or nothing) in binary
and either the raw value or a null in JSON).
Note that the JSON representation is only weakly discriminating.
Specifically, the value [Some None] is represented as the raw value [None]
and so the two are indistinguishable. For this reason, this combinator
does not support nesting, nor does it support use within a recursive
({!mu}) encoding.
@raise Invalid_argument if called on an encoding which may be represented
as [null] in JSON. This includes an encoding of the form [option _],
[conv _ _ (option _)], [dynamic_size (option _)], etc.
@raise Invalid_argument if called within the body of a {!mu}. *)valoption:'aencoding->'aoptionencoding(** Combinator to make a {!result} value
(represented as a 1-byte tag followed by the data of either type in binary,
and either unwrapped value in JSON (the caller must ensure that both
encodings do not collide)). *)valresult:'aencoding->'bencoding->('a,'b)resultencoding(** List combinator.
- encoded as an array in JSON
- encoded as the concatenation of all the element in binary
prefixed its size in bytes
@param [max_length]
If [max_length] is passed and the encoding of elements has fixed
size, a {!check_size} is automatically added for earlier rejection.
@raise Invalid_argument if the inner encoding is variable. *)vallist:?max_length:int->'aencoding->'alistencoding(** List combinator.
- encoded as an array in JSON
- encoded as the concatenation of its length (number of elements) and all
the element in binary
@param kind ([[`N | `Uint8 | `Uint16 | `Uint30]]) controls the
representation of the length: {!uint_like_n}, {!uint8}, {!uint16}, or
{!int31} (but only positive values).
@param [max_length]
If [max_length] is passed and the encoding of elements has fixed
size, a {!check_size} is automatically added for earlier rejection.
@raise Invalid_argument if the inner encoding is variable. *)vallist_with_length:?max_length:int->[`N|`Uint8|`Uint16|`Uint30]->'aencoding->'alistencoding(** Provide a transformer from one encoding to a different one.
Used to simplify nested encodings or to change the generic tuples
built by {!obj1}, {!tup1} and the like into proper records.
A schema may optionally be provided as documentation of the new encoding. *)valconv:('a->'b)->('b->'a)->?schema:json_schema->'bencoding->'aencoding(** [conv_with_guard] is similar to {!conv} but the function that takes in the value
from the outside (untrusted) world has a chance to fail.
Specifically, if the function returns [Error msg] then the decoding is
interrupted with an error carrying the message [msg]. If the function
returns [Ok _] then the decoding proceeds normally. *)valconv_with_guard:('a->'b)->('b->('a,string)result)->?schema:json_schema->'bencoding->'aencoding(** [with_decoding_guard g e] is similar to [e] but decoding fails if [g]
returns [Error _] on the decoded value. *)valwith_decoding_guard:('a->(unit,string)result)->'aencoding->'aencoding(** Association list.
An object in JSON, a list of pairs in binary. *)valassoc:'aencoding->(string*'a)listencoding(** {3 Product descriptors} *)(** An enriched encoding to represent a component in a structured
type, augmenting the encoding with a name and whether it is a
required or optional. Fields are used to encode OCaml tuples as
objects in JSON, and as sequences in binary, using combinator
{!obj1} and the like. *)type'afield(** Required field. *)valreq:?title:string->?description:string->string->'tencoding->'tfield(** Optional field. Omitted entirely in JSON encoding if None.
Omitted in binary if the only optional field in a [`Variable]
encoding, otherwise a 1-byte prefix (`0` or `255`) tells if the
field is present or not. *)valopt:?title:string->?description:string->string->'tencoding->'toptionfield(** Optional field of variable length.
Only one can be present in a given object. *)valvaropt:?title:string->?description:string->string->'tencoding->'toptionfield(** Required field with a default value.
If the default value is passed, the field is omitted in JSON.
The value is always serialized in binary. *)valdft:?title:string->?description:string->string->'tencoding->'t->'tfield(** {4 Constructors for objects with N fields} *)(** These are serialized to binary by converting each internal
object to binary and placing them in the order of the original
object. These are serialized to JSON as a JSON object with the
field names. An object might only contains one 'variable'
field, typically the last one. If the encoding of more than one
field are 'variable', the first ones should be wrapped with
[dynamic_size].
@raise Invalid_argument if more than one field is a variable one. *)valobj1:'f1field->'f1encodingvalobj2:'f1field->'f2field->('f1*'f2)encodingvalobj3:'f1field->'f2field->'f3field->('f1*'f2*'f3)encodingvalobj4:'f1field->'f2field->'f3field->'f4field->('f1*'f2*'f3*'f4)encodingvalobj5:'f1field->'f2field->'f3field->'f4field->'f5field->('f1*'f2*'f3*'f4*'f5)encodingvalobj6:'f1field->'f2field->'f3field->'f4field->'f5field->'f6field->('f1*'f2*'f3*'f4*'f5*'f6)encodingvalobj7:'f1field->'f2field->'f3field->'f4field->'f5field->'f6field->'f7field->('f1*'f2*'f3*'f4*'f5*'f6*'f7)encodingvalobj8:'f1field->'f2field->'f3field->'f4field->'f5field->'f6field->'f7field->'f8field->('f1*'f2*'f3*'f4*'f5*'f6*'f7*'f8)encodingvalobj9:'f1field->'f2field->'f3field->'f4field->'f5field->'f6field->'f7field->'f8field->'f9field->('f1*'f2*'f3*'f4*'f5*'f6*'f7*'f8*'f9)encodingvalobj10:'f1field->'f2field->'f3field->'f4field->'f5field->'f6field->'f7field->'f8field->'f9field->'f10field->('f1*'f2*'f3*'f4*'f5*'f6*'f7*'f8*'f9*'f10)encoding(** Create a larger object from the encodings of two smaller ones.
@raise Invalid_argument if both arguments are not objects or if both
tuples contains a variable field.. *)valmerge_objs:'o1encoding->'o2encoding->('o1*'o2)encoding(** [With_field_name_duplicate_checks] is a subset of [Encoding] where all the
constructed objects are checked for duplicates.
Note that the analysis can include false positives: it might fail on
encodings which will never serialise a value with duplicate fields.
Still, these false positives are uncommon and we recommend you use these
combinators when relevant.
{[
let e =
let open Data_encoding in
let open Data_encoding.With_field_name_duplicate_checks in
…
]}
*)moduleWith_field_name_duplicate_checks:sigvalobj1:'f1field->'f1encodingvalobj2:'f1field->'f2field->('f1*'f2)encodingvalobj3:'f1field->'f2field->'f3field->('f1*'f2*'f3)encodingvalobj4:'f1field->'f2field->'f3field->'f4field->('f1*'f2*'f3*'f4)encodingvalobj5:'f1field->'f2field->'f3field->'f4field->'f5field->('f1*'f2*'f3*'f4*'f5)encodingvalobj6:'f1field->'f2field->'f3field->'f4field->'f5field->'f6field->('f1*'f2*'f3*'f4*'f5*'f6)encodingvalobj7:'f1field->'f2field->'f3field->'f4field->'f5field->'f6field->'f7field->('f1*'f2*'f3*'f4*'f5*'f6*'f7)encodingvalobj8:'f1field->'f2field->'f3field->'f4field->'f5field->'f6field->'f7field->'f8field->('f1*'f2*'f3*'f4*'f5*'f6*'f7*'f8)encodingvalobj9:'f1field->'f2field->'f3field->'f4field->'f5field->'f6field->'f7field->'f8field->'f9field->('f1*'f2*'f3*'f4*'f5*'f6*'f7*'f8*'f9)encodingvalobj10:'f1field->'f2field->'f3field->'f4field->'f5field->'f6field->'f7field->'f8field->'f9field->'f10field->('f1*'f2*'f3*'f4*'f5*'f6*'f7*'f8*'f9*'f10)encoding(** Create a larger object from the encodings of two smaller ones.
@raise Invalid_argument if both arguments are not objects or if both
tuples contains a variable field.. *)valmerge_objs:'o1encoding->'o2encoding->('o1*'o2)encodingend(** {4 Constructors for tuples with N fields} *)(** These are serialized to binary by converting each internal
object to binary and placing them in the order of the original
object. These are serialized to JSON as JSON arrays/lists. Like
objects, a tuple might only contains one 'variable' field,
typically the last one. If the encoding of more than one field
are 'variable', the first ones should be wrapped with
[dynamic_size].
@raise Invalid_argument if more than one field is a variable one. *)valtup1:'f1encoding->'f1encodingvaltup2:'f1encoding->'f2encoding->('f1*'f2)encodingvaltup3:'f1encoding->'f2encoding->'f3encoding->('f1*'f2*'f3)encodingvaltup4:'f1encoding->'f2encoding->'f3encoding->'f4encoding->('f1*'f2*'f3*'f4)encodingvaltup5:'f1encoding->'f2encoding->'f3encoding->'f4encoding->'f5encoding->('f1*'f2*'f3*'f4*'f5)encodingvaltup6:'f1encoding->'f2encoding->'f3encoding->'f4encoding->'f5encoding->'f6encoding->('f1*'f2*'f3*'f4*'f5*'f6)encodingvaltup7:'f1encoding->'f2encoding->'f3encoding->'f4encoding->'f5encoding->'f6encoding->'f7encoding->('f1*'f2*'f3*'f4*'f5*'f6*'f7)encodingvaltup8:'f1encoding->'f2encoding->'f3encoding->'f4encoding->'f5encoding->'f6encoding->'f7encoding->'f8encoding->('f1*'f2*'f3*'f4*'f5*'f6*'f7*'f8)encodingvaltup9:'f1encoding->'f2encoding->'f3encoding->'f4encoding->'f5encoding->'f6encoding->'f7encoding->'f8encoding->'f9encoding->('f1*'f2*'f3*'f4*'f5*'f6*'f7*'f8*'f9)encodingvaltup10:'f1encoding->'f2encoding->'f3encoding->'f4encoding->'f5encoding->'f6encoding->'f7encoding->'f8encoding->'f9encoding->'f10encoding->('f1*'f2*'f3*'f4*'f5*'f6*'f7*'f8*'f9*'f10)encoding(** Create a large tuple encoding from two smaller ones.
@raise Invalid_argument if both values are not tuples or if both
tuples contains a variable field. *)valmerge_tups:'a1encoding->'a2encoding->('a1*'a2)encoding(** {3 Sum descriptors} *)(** A partial encoding to represent a case in a variant type. Hides
the (existentially bound) type of the parameter to the specific
case, providing its encoder, and converter functions to and from
the union type. *)type'tcasetypecase_tag=Tagofint|Json_only(** A sum descriptor can be optimized by providing a specific
[matching_function] which efficiently determines in which case
some value of type ['a] falls.
Note that in general you should use a total function (i.e., one defined
over the whole of the ['a] type) for the [matching_function]. However, in
the case where you have a good reason to use a partial function, you should
raise [No_case_matched] in the dead branches. Reasons why you may want to
do so include:
- ['a] is an open variant and you will complete the matching function
later, and
- there is a code invariant that guarantees that ['a] is not fully
inhabited. *)type'amatching_function='a->match_resultandmatch_result(** [matched t e u] represents the fact that a value is tagged with [t] and
carries the payload [u] which can be encoded with [e].
The optional argument [tag_size] must match the one passed to the
{!matching} function [matched] is called inside of.
An example is given in the documentation of {!matching}.
@raise [Invalid_argument] if [t < 0]
@raise [Invalid_argument] if [t] does not fit in [tag_size] *)valmatched:?tag_size:tag_size->int->'aencoding->'a->match_result(** Encodes a variant constructor. Takes the encoding for the specific
parameters, a recognizer function that will extract the parameters
in case the expected case of the variant is being serialized, and
a constructor function for deserialization.
The tag must be less than the tag size of the union in which you use the case.
An optional tag gives a name to a case and should be used to maintain
compatibility.
An optional name for the case can be provided, which is used in the binary
documentation.
@raise [Invalid_argument] if [case_tag] is [Tag t] with [t < 0] *)valcase:title:string->?description:string->case_tag->'aencoding->('t->'aoption)->('a->'t)->'tcase(** Create a single encoding from a series of cases.
In JSON, all cases are tried one after the other using the [case list]. The
caller is responsible for avoiding collisions. If there are collisions
(i.e., if multiple cases produce the same JSON output) then the encoding
and decoding processes might not be inverse of each other. In other words,
[destruct e (construct e v)] may not be equal to [v].
In binary, a prefix tag is added to discriminate quickly between
cases. The default is [`Uint8] and you must use a [`Uint16] if
you are going to have more than 256 cases.
The matching function is used during binary encoding of a value
[v] to efficiently determine which of the cases corresponds to
[v]. The case list is used during decoding to reconstruct a value based on
the encoded tag. (Decoding is optimised internally: tag look-up has a
constant cost.)
The caller is responsible for ensuring that the [matching_function] and the
[case list] describe the same encoding. If they describe different
encodings, then the decoding and encoding processes will not be inverses of
each others. In other words, [of_bytes e (to_bytes e v)] will not be equal
to [v].
If you do not wish to be responsible for this, you can use the unoptimised
{!union} that uses a [case list] only (see below). Beware that in {!union}
the complexity of the encoding is linear in the number of cases.
Following: a basic example use. Note that the [matching_function] uses the
same tags, payload conversions, and payload encoding as the [case list].
{[
type t = A of string | B of int * int | C
let encoding_t =
(* Tags and payload encodings for each constructors *)
let a_tag = 0 and a_encoding = string in
let b_tag = 1 and b_encoding = obj2 (req "x" int) (req "y" int) in
let c_tag = 2 and c_encoding = unit in
matching
(* optimised encoding function *)
(function
| A s -> matched a_tag a_encoding s
| B (x, y) -> matched b_tag b_encoding (x, y)
| C -> matched c_tag c_encoding ())
(* decoding case list *)
[
case ~title:"A"
(Tag a_tag)
a_encoding
(function A s -> Some s | _ -> None) (fun s -> A s);
case ~title:"B"
(Tag b_tag)
b_encoding
(function B (x, y) -> Some (x, y) | _ -> None) (fun (x, y) -> B (x, y));
case ~title:"C"
(Tag c_tag)
c_encoding
(function C -> Some () | _ -> None) (fun () -> C);
]
]}
@raise [Invalid_argument] if it is given an empty [case list]
@raise [Invalid_argument] if there are more than one [case] with the same
[tag] in the [case list]
@raise [Invalid_argument] if there are more cases in the [case list] than
can fit in the [tag_size] *)valmatching:?tag_size:tag_size->'tmatching_function->'tcaselist->'tencoding(** Same as matching except that the matching function is
a linear traversal of the cases.
@raise [Invalid_argument] if it is given an empty [case list]
@raise [Invalid_argument] if there are more than one [case] with the same
[tag] in the [case list]
@raise [Invalid_argument] if there are more cases in the [case list] than
can fit in the [tag_size] *)valunion:?tag_size:tag_size->'tcaselist->'tencoding(** [With_JSON_discriminant] is a subset of [Encoding] where the
union/matching combinators (and associated functions) add discriminant for
the JSON backend.
The following restrictions apply:
- The case encodings must be objects.
- The case encoding objects must not include a "kind" field.
- The case encoding objects must not have duplicate field names.
- The JSON discriminants must all be distinct.
{[
let e =
let open Data_encoding in
let open Data_encoding.With_JSON_discriminant in
…
]} *)moduleWith_JSON_discriminant:sig(** [case_tag]'s only variant [Tag] includes both a numeric tag for the binary
encoding and a string tag for the JSON encoding. *)typecase_tag=Tagof(int*string)type'tcase(** [case] is similar to [Encoding.case] but it takes a
[SaferEncoding.case_tag] parameter. This includes both a numeric tag and a
string tag.
In Binary:
This has no impact. The [case_tag] argument of [Encoding] already has a
numeric tag.
In JSON:
The [SaferEncoding] adds a field for discriminating the different cases,
making these encodings less likely to include accidental bugs. More
specifically, when you use [case (Tag (_, s)) e _ _] then the underlying
union uses an encoding based on [e] and [s]. Specifically, if [e] is an
object encoding, then it adds the field [(req "kind" (constant s))] to
[e].
@raise Invalid_argument if [e] is not an object.
@raise Invalid_argument if [e] is an object with a ["kind"] field (this
field name is reserved for the discriminating field added by [case]). *)valcase:title:string->?description:string->case_tag->'aencoding->('t->'aoption)->('a->'t)->'tcase(** [union] and [matching] now check that there are no duplicate ["kind"]
discriminating values. If there is, they raises [Invalid_argument]. *)(** Similarly to [case_tag], [matched] also takes an additional [string]
parameter. This parameter is used in the same way as [case] (to add a ["kind"] field
to the JSON encoding) and it fails in the same way as [case].
@raise Invalid_argument if the encoding is not an object.
@raise Invalid_argument if the encoding is an object with a ["kind"]
field. *)valmatched:?tag_size:tag_size->int*string->'aencoding->'a->match_resultvalmatching:?tag_size:tag_size->'tmatching_function->'tcaselist->'tencodingvalunion:?tag_size:tag_size->'tcaselist->'tencodingend(** {3 Specialized descriptors} *)(** Encode enumeration via association list
- represented as a string in JSON and
- represented as an integer representing the element's position
in the list in binary. The integer size depends on the list size.*)valstring_enum:(string*'a)list->'aencoding(** Create encodings that produce data of a fixed length when binary encoded.
See the preamble for an explanation. *)moduleFixed:sig(** @raise Invalid_argument if the argument is less or equal to zero. *)valstring:string_json_repr->int->stringencoding(** @raise Invalid_argument if the argument is less or equal to zero. *)valbytes:string_json_repr->int->Bytes.tencoding(** [add_padding e n] is a padded version of the encoding [e]. In Binary,
there are [n] null bytes ([\000]) added after the value encoded by [e].
In JSON, padding is ignored.
@raise Invalid_argument if [n <= 0]. *)valadd_padding:'aencoding->int->'aencoding(** [list n e] is an encoding for lists of exactly [n] elements. If a list
of more or fewer elements is provided, then the encoding fails with the
[write_error List_invalid_length]. For decoding, it can fail with
[read_error Not_enough_data] or [read_error Extra_bytes], or it may
cause other failures further down the line when the AST traversal
becomes out-of-sync with the underlying byte-stream traversal.
The difference of the errors being used when encoding and decoding is
because when encoding we have access to the list and we can check the
actual length, whereas when decoding we only see bytes, sometimes too
many, sometimes not enough.
This encoding has a narrow set of possible applications because it is
very restrictive. Still, it can to:
- mirror static guarantees about the length of some lists,
- special-case some common lengths of typical input in a union (see
example below),
- other ends.
{[
type expr =
| Op of string * expr list (* most commonly 1 or 2 operands *)
| Literal of string
let expr_encoding =
mu "expr" (fun e ->
union [
case ~title:"op-nonary" (Tag 0)
string
(function Op (op, []) -> Some op | _ -> None)
(fun op -> Op (op, []));
case ~title:"op-unary" (Tag 1)
(tup2 string (Fixed.list 1 e))
(function Op (op, ([_]) as operand) -> Some (op, operand) | _ -> None)
(fun (op, operand) -> Op (op, operand));
case ~title:"op-binary" (Tag 2)
(tup2 string (Fixed.list 2 e))
(function Op (op, ([_;_]) as operand) -> Some (op, operand) | _ -> None)
(fun (op, operand) -> Op (op, operand));
case ~title:"op-moreary" (Tag 3)
(tup2 string (list e))
(function Op (op, operand) -> Some (op, operand) | _ -> None)
(fun (op, operand) -> Op (op, operand));
case ~title:"literal" (Tag 4)
string
(function Literal l -> Some l | _ -> None)
(fun l -> Literal l);
]
)
]}
Interestingly, the cases for known lengths can be generated
programmatically.
@raise Invalid_argument if the argument [n] is less or equal to zero.
@raise Invalid_argument if the argument [e] is a [`Variable]-size
encoding or a zero-byte encoding. *)vallist:int->'aencoding->'alistencoding(** See [list] above.
@raise Invalid_argument if the argument [n] is less or equal to zero.
@raise Invalid_argument if the argument [e] is a [`Variable]-size
encoding or a zero-byte encoding. *)valarray:int->'aencoding->'aarrayencodingend(** Create encodings that produce data of a variable length when binary encoded.
See the preamble for an explanation. *)moduleVariable:sigvalstring:string_json_repr->stringencodingvalbytes:string_json_repr->Bytes.tencoding(** @raise Invalid_argument if the encoding argument is variable length
or may lead to zero-width representation in binary. *)valarray:?max_length:int->'aencoding->'aarrayencoding(** @raise Invalid_argument if the encoding argument is variable length
or may lead to zero-width representation in binary. *)vallist:?max_length:int->'aencoding->'alistencodingendmoduleBounded:sig(** Encoding of a string whose length does not exceed the specified length.
If [length_kind] is set, then it is used to encode the length of the
string in a header. If [length_kind] is omitted then the length field
uses the smallest fixed-width integer that can accommodate the
maximum size - e.g., [`Uint8] for very short strings, [`Uint16] for
longer strings, etc.
Attempting to construct a string with a length that is too long causes
an [Invalid_argument] exception.
@raise Invalid_argument if [length_kind] is set but it cannot accommodate
the specified bound. E.g.,
[Bounded.string ~length_kind:`Uint8 Hex 1000] raises.
@raise Invalid_argument if [length_kind] is unset and the specified
bound is larger than 2^30. *)valstring:?length_kind:[`N|`Uint30|`Uint16|`Uint8]->string_json_repr->int->stringencoding(** See {!string} above. *)valbytes:?length_kind:[`N|`Uint30|`Uint16|`Uint8]->string_json_repr->int->Bytes.tencodingend(** Mark an encoding as being of dynamic size.
Forces the size to be stored alongside content when needed.
Typically used to combine two variable encodings in a same
objects or tuple, or to use a variable encoding in an array or a list. *)valdynamic_size:?kind:[`N|`Uint30|`Uint16|`Uint8]->'aencoding->'aencoding(** [check_size size encoding] ensures that the binary encoding
of a value will not be allowed to exceed [size] bytes. The reader
and the writer fails otherwise. This function do not modify
the JSON encoding.
@raise Invalid_argument if [size < 0] *)valcheck_size:int->'aencoding->'aencoding(** Define different encodings for JSON and binary serialization. *)valsplitted:json:'aencoding->binary:'aencoding->'aencoding(** Combinator for recursive encodings.
Notice that the function passed to [mu] must be pure. Otherwise,
the behavior is unspecified.
A stateful recursive encoding can still be put under a [delayed]
combinator to make sure that a new encoding is generated each
time it is used. Caching the encoding generation when the state
has not changed is then the responsibility of the client.
*)valmu:string->?title:string->?description:string->('aencoding->'aencoding)->'aencoding(** {3 Documenting descriptors} *)(** Give a name to an encoding and optionally
add documentation to an encoding. *)valdef:string->?title:string->?description:string->'tencoding->'tencoding(** See {!lazy_encoding} below.*)type'alazy_t(** Combinator to have a part of the binary encoding lazily deserialized.
This is transparent on the JSON side. *)vallazy_encoding:'aencoding->'alazy_tencoding(** Force the decoding (memoized for later calls), and return the
value if successful. *)valforce_decode:'alazy_t->'aoption(** Obtain the bytes without actually deserializing. Will serialize
and memoize the result if the value is not the result of a lazy
deserialization. *)valforce_bytes:'alazy_t->bytes(** Make a lazy value from an immediate one. *)valmake_lazy:'aencoding->'a->'alazy_t(** Apply on structure of lazy value, and combine results *)valapply_lazy:fun_value:('a->'b)->fun_bytes:(bytes->'b)->fun_combine:('b->'b->'b)->'alazy_t->'bmoduleCompact:sig(** This module provides specialized encoding combinators that are
implemented to reduce the size of the serialization result.
The main trick this module relies on is the notion of “shared tags”.
In [Data_encoding], the [union] combinator uses (at least) one byte
every time it is used, to “tag” the output and distinguish between
various disjunction cases. As a consequence, if [n] [union] are
composed together to define one encoding, (at least) [n] bytes are
being allocated. However, in practice, only few bits are used in
each tags, which means the rest is “wasted.”
As an example, consider this type:
{[
type t =
| T1 of { f1 : int option; f2 : (int, bool) Either.t }
| T2 of { f3: int }
]}
A value of [t] using the constructor [T1] will be serialized into
a binary array of this form:
{v
┌────────┬─────────┬─────────────┬─────────┬─────────────┐
│ tag(t) │ tag(f1) │ payload(f1) │ tag(f2) │ payload(f2) │
└────────┴─────────┴─────────────┴─────────┴─────────────┘
1 byte 1 byte N bytes 1 byte M bytes
v}
Where [tag(f)] is a value used by [Data_encoding] to distinguish
between several encoding alternatives for [f], and [payload(f)] is
the resulting binary array.
For both [option] and [Either.t], the tag of the encoding only uses
one bit in practice. Which means that for [T1], encoding the pair
[(f1, f2)] needs two bits, but the default approach of
[Data_encoding] uses two {i bytes} instead. Similarly, to
distinguish between [T1] and [T2] needs one bit, but the default
approach is to use an additional tag (one additional {i byte}).
This module provides an approach to tackle this issue, by
allocating only one tag ({i i.e.}, one byte) that is used to store
the useful bits to distinguish between the disjunction cases. We
call this tag the “shared tag” of the encoding. The bits of the
shared tag describes precisely the layout of the encoded data.
For instance, considering a compact encoding for [t], the third
bit of the tag can be used to distinguish between [T1] and [T2].
In case the third bit is 0, the first bit of the tag determines
the case of [option], and the second the case of [Either.t].
As a consequence the resulting binary array for the constructor
[T1] is, using
- [_] to represent meaningless bits,
- [0] and [1] to represent actual bit values,
- [e] to represent the bit used to distinguish the [Either] case of [f2], and
- [o] to represent the bit used to distinguish the [Option] case of [f1]:
{v
┌──────────┬─────────────┬─────────────┐
│ _____0eo │ payload(f1) │ payload(f2) │
└──────────┴─────────────┴─────────────┘
1 byte N bytes M bytes
v}
while the resulting binary array for the constructor [T2] is
{v
┌──────────┬─────────────┐
│ _____100 │ payload(f3) │
└──────────┴─────────────┘
1 byte N bytes
v} *)(** The description of a compact encoding. *)type'at(** Turn a compact encoding into a regular {!Data_encoding.t}.
@param tag_size controls the size of the tag used to discriminate the
values. Note that in data-encoding, all the writes and reads are byte
aligned so the tag must fit in either 0 ([`Uint0]), 1 ([`Uint8]), or 2
([`Uint16]) bytes.
The default is [`Uint0], i.e., no tag at all. This is can only represent
values which use 0 bits of tags.
It is recommended to set the [tag_size] explicitly.
@raise Invalid_argument if the shared tags cannot fit in [tag_size]
space. *)valmake:?tag_size:[`Uint0|`Uint8|`Uint16]->'at->'aencoding(** [tag_bit_count c] is the number of bits of tag that a compact encoding
uses. *)valtag_bit_count:'at->int(** {1 Combinators} *)(** Similarly to [Data_encoding], we provide various combinators to
compose compact encoding together. *)(** {2 Base types} *)(** A type with no inhabitant. *)typevoid(** A compact encoding used to denote an impossible case inside of
conjunction operators such as [union].
Uses 0 bit of tag. *)valvoid:voidt(** [refute x] can be used to refute a branch of a [match] which
exhibits a value of type [void]. *)valrefute:void->'a(** A compact encoding of the singleton value [unit], which has zero
memory footprint.
Uses zero (0) bits of tag.
In JSON it is represented as the empty object [{}]. *)valunit:unitt(** A compact encoding of the singleton value [unit], which has zero
memory footprint.
Uses zero (0) bits of tag.
In JSON it is represented as [null]. *)valnull:unitt(** Efficient encoding of boolean values. It uses one (1) bit in the
shared tag, and zero bit in the payload. *)valbool:boolt(** [payload encoding] unconditionally uses [encoding] in the
payload, and uses zero (0) bit in the shared tag. *)valpayload:'aencoding->'at(** Uses one (1) bit in the tag to encode an option. *)valoption:'at->'aoptiont(** {2 Conversion} *)(** [conv ?json f g e] reuses the encoding [e] for type [b] to encode
a type [a] using the isomorphism [(f, g)]. The optional argument
allows to overwrite the encoding used for JSON, in place of the
one computed by default. *)valconv:?json:'aencoding->('a->'b)->('b->'a)->'bt->'at(** {2 Conjunctions} *)(** [tup1 e] wraps the underlying encoding of [e] in a [tup1] (from the
parent module). This is only useful in that, provided you use
[make ~tag_size:`Uint0] to translate the returned compact encoding, it
allows you to call [merge_tups] on it.
Uses as many bits of tag as [e]. *)valtup1:'at->'at(** [tup2 e1 e2] concatenates the shared tags and payloads of [e1] and
[e2].
Uses as many bits of tags as the sum of the tags used by its arguments. *)valtup2:'at->'bt->('a*'b)t(** [tup3 e1 e2 e3] concatenates the shared tags and payloads of [e1],
[e2], and [e3].
Uses as many bits of tags as the sum of the tags used by its arguments. *)valtup3:'at->'bt->'ct->('a*'b*'c)t(** [tup4 e1 e2 e3 e4] concatenates the shared tags and payloads of
[e1], [e2], [e3] and [e4].
Uses as many bits of tags as the sum of the tags used by its arguments. *)valtup4:'at->'bt->'ct->'dt->('a*'b*'c*'d)tvaltup5:'f1t->'f2t->'f3t->'f4t->'f5t->('f1*'f2*'f3*'f4*'f5)tvaltup6:'f1t->'f2t->'f3t->'f4t->'f5t->'f6t->('f1*'f2*'f3*'f4*'f5*'f6)tvaltup7:'f1t->'f2t->'f3t->'f4t->'f5t->'f6t->'f7t->('f1*'f2*'f3*'f4*'f5*'f6*'f7)tvaltup8:'f1t->'f2t->'f3t->'f4t->'f5t->'f6t->'f7t->'f8t->('f1*'f2*'f3*'f4*'f5*'f6*'f7*'f8)tvaltup9:'f1t->'f2t->'f3t->'f4t->'f5t->'f6t->'f7t->'f8t->'f9t->('f1*'f2*'f3*'f4*'f5*'f6*'f7*'f8*'f9)tvaltup10:'f1t->'f2t->'f3t->'f4t->'f5t->'f6t->'f7t->'f8t->'f9t->'f10t->('f1*'f2*'f3*'f4*'f5*'f6*'f7*'f8*'f9*'f10)ttype'afield(** [req "f" compact] can be used in conjunction with [objN] to create
compact encoding with more readable JSON encoding, as an
alternative of [tupN]. The JSON output is a dictionary which
contains the field [f] with a value encoded using [compact]. *)valreq:string->'at->'afield(** Same as {!req}, but the field is optional.
An [objN] compact encoding uses as many bits of tags as its number of
[opt] fields. *)valopt:string->'at->'aoptionfield(** [obj1] can be used in conjunction with [req] or [opt] to produce
more readable JSON outputs.
Uses as many bits of tags as there are [opt] fields in its arguments. *)valobj1:'afield->'at(** An alternative to [tup2] which can be used in conjunction with
{!req} and {!opt} to produce more readable JSON outputs based on
dictionary.
Uses as many bits of tags as there are [opt] fields in its arguments. *)valobj2:'afield->'bfield->('a*'b)t(** An alternative to [tup3] which can be used in conjunction with
{!req} and {!opt} to produce more readable JSON outputs based on
dictionary.
Uses as many bits of tags as there are [opt] fields in its arguments. *)valobj3:'afield->'bfield->'cfield->('a*'b*'c)t(** An alternative to [tup4] which can be used in conjunction with
{!req} and {!opt} to produce more readable JSON outputs based on
dictionary.
Uses as many bits of tags as there are [opt] fields in its arguments. *)valobj4:'afield->'bfield->'cfield->'dfield->('a*'b*'c*'d)tvalobj5:'f1field->'f2field->'f3field->'f4field->'f5field->('f1*'f2*'f3*'f4*'f5)tvalobj6:'f1field->'f2field->'f3field->'f4field->'f5field->'f6field->('f1*'f2*'f3*'f4*'f5*'f6)tvalobj7:'f1field->'f2field->'f3field->'f4field->'f5field->'f6field->'f7field->('f1*'f2*'f3*'f4*'f5*'f6*'f7)tvalobj8:'f1field->'f2field->'f3field->'f4field->'f5field->'f6field->'f7field->'f8field->('f1*'f2*'f3*'f4*'f5*'f6*'f7*'f8)tvalobj9:'f1field->'f2field->'f3field->'f4field->'f5field->'f6field->'f7field->'f8field->'f9field->('f1*'f2*'f3*'f4*'f5*'f6*'f7*'f8*'f9)tvalobj10:'f1field->'f2field->'f3field->'f4field->'f5field->'f6field->'f7field->'f8field->'f9field->'f10field->('f1*'f2*'f3*'f4*'f5*'f6*'f7*'f8*'f9*'f10)t(** A compact encoding for [int32] values. It uses 2 bits in the
shared tag, to determine how many bytes are used in the payload:
{ul {li [00]: from 0 to 255, one byte.}
{li [01]: from 256 to 65,535, two bytes.}
{li [10]: from 65,536 to [Int32.max_int] and for negative values, four bytes.}}
Note that by itself, this compact encoding is not necessarily more
economical in space. However, in combination with other compact
encodings (say, when you have two bits of tag to spare anyway) or given
a very skewed distribution of values (say, when the vast majority of
your values are in the 0–255 interval), then it can help you save some
space.
Uses two (2) bits of tag. *)valint32:int32t(** A compact encoding for [int64] values. It uses 2 bits in the
shared tag, to determine how many bytes are used in the payload:
{ul {li [00]: from 0 to 255, one byte.}
{li [01]: from 256 to 65,535, two bytes.}
{li [10]: from 65,536 to 4,294,967,295 four bytes.}
{li [11]: from 4,294,967,295 and for negative values eight bytes.}}
See {!int32} for usage recommendations.
Uses two (2) bits of tag. *)valint64:int64t(** [list ~bits:n encoding] uses [n] bits in the shared tag to encode the
size of small lists.
For instance, [list ~bits:2 encoding],
{ul {li [00]: the payload is empty, because it is the empty list}
{li [01]: the singleton list, whose element is encoded using
[encoding].}
{li [10]: a list of two elements encoded with [encoding]}
{li [11]: a list of more than two elements, prefixed with its
encoded size (i.e., the number of bytes it takes to represent
the whole value) (which uses 4 bytes)}}
With [~bits:3], lists of 0 to 6 items are encoded with tags [000] to
[110], and lists of 7 or more are encoded with tag [111] and the
length.
Uses [n] bits of tags. *)vallist:bits:int->'aencoding->'alistt(** {2 Disjunctions} *)type'acase(** Usage: [case name encode decode encoding]
Intended to be used inside a [union]. *)valcase:title:string->?description:string->'bt->('a->'boption)->('b->'a)->'acase(** [union cases] creates a new compact encoding to encompass a
disjunction of cases.
The value uses some tag bits to distinguish the different cases of the
union (see discussion of parameter [union_tag_bits]) and some tag bits
(potentially 0) to distinguish the values within a case (see discussion
of parameter [cases_tag_bits]).
E.g., Given [type t = A of bool | B of int option] and the encoding
{v
let c =
union [
case "A" (function A b -> Some b | _ -> None) (fun b -> A b) bool;
case "B" (function B i -> Some i | _ -> None) (fun i -> B b) (option (payload int));
in
make ~tag_size:`Uint8 c
v}
then a value can have either of the following 4 tags:
- 0b00000000: case [A], [false]
- 0b00000001: case [A], [true]
- 0b00000010: case [B], [Some] (a payload of 4 bytes follows)
- 0b00000011: case [B], [None]
In other words, the second bit of this tag is used to discriminate the
cases of the union, whilst the first bit is used to discriminate within
each case.
Note that the compact union can be combined with more compact encoding
before being passed to [make] in which case the two bits of tags will be
combined with the tags of the other compact encodings. E.g.,
[make ~tag_size:`Uint8 (tup2 c c)].
@param union_tag_bits is the number of bits used to distinguish the
different cases of the union. For example, if the union has 4 cases
(i.e., if [List.length cases = 4]) then you can use [~union_tag_bits:2].
If not provided explicitly, [union_tag_bits] is inferred: it is set to
the smallest value which can accommodate the provided [cases].
It is recommended to set [union_tag_bits] explicitly.
You can over-provision the [union_tag_bits] if you expect the
[cases] to grow in the future.
@raise Invalid_argument if the value passed for [union_tag_bits] is not
sufficient to distinguish between the [cases].
@param cases_tag_bits is the number of bits that each of the [cases] can
use. This is only useful if the cases use more than 0 bits of tag.
It is recommended to set [cases_tag_bits] explicitly if you need the
layout to be stable even if the [cases] or one of its element changes.
You can over-provision the [cases_tag_bits] if you expect one of the
cases to change to use more bits of tag or if you expect that a new case
using more tag bits will be added in the future.
E.g., passing [~cases_tag_bits:7] to the [union] in the example above
will cause the values to be represented as follows:
- 0b00000000: case [A], [false]
- 0b00000001: case [A], [true]
- 0b10000000: case [B], [Some] (a payload of 4 bytes follows)
- 0b10000001: case [B], [None]
@raise Invalid_argument if one of the elements of [cases] needs more
than [cases_tag_bits] bits of tag.
E.g., [union ~cases_tag_bits:0 [case "Bool" Option.some Fun.id bool]]
raises [Invalid_argument] because {!bool} uses one bit of tag which is
more than [0].
@raise Invalid_argument if [cases] is empty. *)valunion:?union_tag_bits:int->?cases_tag_bits:int->'acaselist->'at(** [void_case ~title] is an impossible case. It is provided so you can add
unused tags within a union. E.g.,
[union [case _; void_case ~title:"reserved-for-v04-compatibility"; case _; case _]]
uses two bits of tag for the discrimination of the union,
but the tag [01] is unused (reserved for some version compatibility). *)valvoid_case:title:string->'acase(** [or_int32 ~i32_title ~alt_title ?alt_description c] creates a new
compact encoding for the disjunction of
any type [a] (see {!val-case}) with [int32]. It uses the same number
of bits as {!int32}, that is 2, and uses the spare tag ([11]) within
this size for values of type [a].
@param i32_title is used as a prefix to each of the int32 cases' title.
@param alt_title is used as the title of the alt case. (See {!val-case} and
{!union} for details.)
@param alt_description is used as the description of the alternate case.
(See {!val-case} and {!union} for details.) *)valor_int32:int32_title:string->alt_title:string->?alt_description:string->'aencoding->(int32,'a)Either.tt(** {1 Custom} *)(** This module can be used to write compact encoding for complex types
without relying on the existing combinators. *)moduleCustom:sigtypetag=int(** Combine multiple tags; will throw an error if the total length of
the tags is more than 16. *)valjoin_tags:(tag*int)list->tagmoduletypeS=sig(** The type of [input] this module allows to encode. *)typeinput(** The various ways to efficiently encode [input]. *)typelayout(** The list of layouts available to encode [input]. *)vallayouts:layoutlist(** The number of bits necessary to distinguish between the various
layouts. *)valtag_len:int(** [tag layout] computes the tag of {!Data_encoding.union} to be
used to encode values classified as [layout].
{b Warning:} It is expected that [tag layout < 2^tag_len - 1]. *)valtag:layout->tag(** [partial_encoding layout] returns the encoding to use for values
classified as [layout].
This encoding can be partial in the sense that it may fail (it
will raise an [Invalid_argument]) for some values of [x].
However, it is expected that [partial_encoding (classify x) x]
will always succeed. *)valpartial_encoding:layout->inputencoding(** [classify x] returns the layout to be used to encode [x]. *)valclassify:input->layout(** The encoding to use when targeting a JSON output. *)valjson_encoding:inputencodingend(** [make (module M)] is a compact encoding for the type of [M.input].
The JSON representation is entirely determined by [M.json_encoding].
The binary representation is determined as follows.
- A value [v : M.input] is classified into a layout [l] by [M.classify v].
- A tag [M.tag l] is used (which may be combined with the tags of other
compact encodings as described before).
- The payload is the same bytes as can be found in the string returned by
[Data_encoding.Binary.to_string (M.partial_encoding l) v].
In other words, the tag of a value is [M.(tag (layout v))] and the payload
of a value is [M.(partial_encoding (layout v) v)].
It is the user's responsibility to ensure that all the values of [M]
follow the invariants documented in {!module-type-S}. *)valmake:(moduleSwithtypeinput='a)->'atendendtype'acompact='aCompact.tvaljson:jsonencodingvaljson_schema:json_schemaencodingmoduleJson:sigvalschema:?definitions_path:string->'aencoding->json_schema(** Construct a JSON object from an encoding. *)valconstruct:?include_default_fields:[`Always|`Auto|`Never]->'tencoding->'t->json(** Destruct a JSON object into a value.
Fail with an exception if the JSON object and encoding do not match.
@param [bson_relaxation] (default to [false]) works around a limitation of
the BSON format. Specifically, in BSON, top-level arrays are represented as
number-indexed objects. When [bson_relaxation] is [true], then the
destructor attempts to automatically translate the indistinguishable
values as guided by the encoding. *)valdestruct:?bson_relaxation:bool->'tencoding->json->'t(** JSON Error *)typepath=path_itemlist(** A set of accessors that point to a location in a JSON object. *)andpath_item=[`Fieldofstring(** A field in an object. *)|`Indexofint(** An index in an array. *)|`Star(** Any / every field or index. *)|`Next(** The next element after an array. *)](** Exception raised by destructors, with the location in the original
JSON structure and the specific error. *)exceptionCannot_destructof(path*exn)(** Unexpected kind of data encountered, with the expectation. *)exceptionUnexpectedofstring*string(** Some {!val:union} couldn't be destructed, with the reasons for each {!val:case}. *)exceptionNo_case_matchedofexnlist(** Array of unexpected size encountered, with the expectation. *)exceptionBad_array_sizeofint*int(** Missing field in an object. *)exceptionMissing_fieldofstring(** Supernumerary field in an object. *)exceptionUnexpected_fieldofstringvalprint_error:?print_unknown:(Format.formatter->exn->unit)->Format.formatter->exn->unit(** Helpers for writing encoders. *)valcannot_destruct:('a,Format.formatter,unit,'b)format4->'avalwrap_error:('a->'b)->'a->'bvalpp:Format.formatter->json->unitendmoduleBinary:sig(** Compute the expected length of the binary representation of a value.
@raise Write_error in case some size/length invariants are broken.
*)vallength:'aencoding->'a->int(** Returns the size of the binary representation that the given
encoding might produce, only when this size does not depends of the value
itself.
E.g., [fixed_length (tup2 int64 (Fixed.string 2))] is [Some _]
E.g., [fixed_length (result int64 (Fixed.string 2))] is [None]
E.g., [fixed_length (list (tup2 int64 (Fixed.string 2)))] is [None] *)valfixed_length:'aencoding->intoption(** Returns the maximum size of the binary representation that the given
encoding might produce, only when this maximum size does not depends of
the value itself.
E.g., [maximum_length (tup2 int64 (Fixed.string 2))] is [Some _]
E.g., [maximum_length (result int64 (Fixed.string 2))] is [Some _]
E.g., [maximum_length (list (tup2 int64 (Fixed.string 2)))] is [None]
Note that the function assumes that recursive encodings (build using [mu])
are used for recursive data types. As a result, [maximum_length] will
return [None] if given a recursive encoding.
If there are static guarantees about the maximum size of the
representation for values of a given type, you can wrap your encoding in
[check_size]. This will cause [maximum_length] to return [Some _]. *)valmaximum_length:'aencoding->intoptionvalof_bytes_opt:'aencoding->bytes->'aoptionvalof_string_opt:'aencoding->string->'aoptionvalto_bytes_opt:?buffer_size:int->'aencoding->'a->bytesoption(** [to_bytes_exn enc v] is equivalent to [to_bytes enc v], except
@raise [Write_error] instead of returning [None] in case of error. *)valto_bytes_exn:?buffer_size:int->'aencoding->'a->bytesvalto_string_opt:?buffer_size:int->'aencoding->'a->stringoption(** @raise [Write_error] instead of returning [None] in case of error. *)valto_string_exn:?buffer_size:int->'aencoding->'a->stringendend# 34 "v8.in.ml"moduleRaw_hashes:sig# 1 "v8/raw_hashes.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)valblake2b:bytes->bytesvalsha256:bytes->bytesvalsha512:bytes->bytesvalkeccak256:bytes->bytesvalsha3_256:bytes->bytesvalsha3_512:bytes->bytesend# 36 "v8.in.ml"moduleCompare:sig# 1 "v8/compare.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2021 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** {1 [Compare]}
Monomorphic comparison for common ground types and common type constructors.
[Compare] provides a module signature for the standard comparison functions
and operators as well as modules of that signature for the common OCaml
ground types ([int], [bool], etc.) and type constructors ([list], [option],
etc.).
[Compare] also provides some additional helpers for comparison-related
tasks. *)(** {2 Signatures and a functor} *)(** [COMPARABLE] is a signature for basic comparison. It is used only for
instantiating full comparison modules of signature {!module-type-S} via the
functor {!Make}. *)moduletypeCOMPARABLE=sigtypetvalcompare:t->t->intend(** [S] is a signature for a fully-fledge comparison module. It includes all the
functions and operators derived from a [compare] function. *)moduletypeS=sigtypet(** [x = y] iff [compare x y = 0] *)val(=):t->t->bool(** [x <> y] iff [compare x y <> 0] *)val(<>):t->t->bool(** [x < y] iff [compare x y < 0] *)val(<):t->t->bool(** [x <= y] iff [compare x y <= 0] *)val(<=):t->t->bool(** [x >= y] iff [compare x y >= 0] *)val(>=):t->t->bool(** [x > y] iff [compare x y > 0] *)val(>):t->t->bool(** [compare] an alias for the functor parameter's [compare] function *)valcompare:t->t->int(** [equal x y] iff [compare x y = 0] *)valequal:t->t->bool(** [max x y] is [x] if [x >= y] otherwise it is [y] *)valmax:t->t->t(** [min x y] is [x] if [x <= y] otherwise it is [y] *)valmin:t->t->tendmoduleMake(P:COMPARABLE):Swithtypet:=P.t(** {2 Base types}
The specialised comparison and all the specialised functions and operators
on the base types are compatible with the polymorphic comparison and all the
polymorphic functions and operators from the {!Stdlib}. *)moduleChar:Swithtypet=charmoduleBool:Swithtypet=bool(** [Int] is a comparison module. Out of performance concerns, the signature
actually contains compiler builtins ([external]) rather than [val]. *)moduleInt:sigtypet=intexternal(=):int->int->bool="%equal"external(<>):int->int->bool="%notequal"external(<):int->int->bool="%lessthan"external(>):int->int->bool="%greaterthan"external(<=):int->int->bool="%lessequal"external(>=):int->int->bool="%greaterequal"externalcompare:int->int->int="%compare"valmax:int->int->intvalmin:int->int->intexternalequal:int->int->bool="%equal"endmoduleInt32:Swithtypet=int32moduleUint32:Swithtypet=int32moduleInt64:Swithtypet=int64moduleUint64:Swithtypet=int64moduleString:Swithtypet=stringmoduleBytes:Swithtypet=bytes(** [Z] is a comparison module for Zarith numbers. *)moduleZ:Swithtypet=Z.t(** [Q] is a comparison module for Zarith rationals. *)moduleQ:Swithtypet=Q.t(** {2 Type constructors}
Provided the functor argument(s) are compatible with the polymorphic
comparison of the {!Stdlib}, then the specialised comparison and all the
specialised functions and operators on the derived types are compatible with
the polymorphic comparison and all the polymorphic functions and operators
from the {!Stdlib}. *)moduleList(P:COMPARABLE):Swithtypet=P.tlistmoduleOption(P:COMPARABLE):Swithtypet=P.toptionmoduleResult(Ok:COMPARABLE)(Error:COMPARABLE):Swithtypet=(Ok.t,Error.t)result(** {2 List lengths}
Helpers for more readable {!Stdlib.List.compare_lengths} and
{!Stdlib.List.compare_length_with}.
These modules are intended to be used as [Module.(expression)], most often
within an [if] condition. E.g.,
{[
if Compare.List_length_with.(chunks > max_number_of_chunks) then
raise Maximum_size_exceeded
else
..
]}
*)moduleList_length_with:sig(** [Compare.List_length_with.(l = n)] iff [l] is of length [n]. In other
words iff [Stdlib.List.compare_length_with l n = 0]. Note that, like
[compare_length_with], this comparison does not explore the list [l]
beyond its [n]-th element. *)val(=):'alist->int->bool(** [Compare.List_length_with.(l <> n)] iff [l] is not of length [n]. In other
words iff [Stdlib.List.compare_length_with l n <> 0]. Note that, like
[compare_length_with], this comparison does not explore the list [l]
beyond its [n]-th element. *)val(<>):'alist->int->bool(** [Compare.List_length_with.(l < n)] iff [l] is of length strictly less than
[n]. In other words iff [Stdlib.List.compare_length_with l n < 0]. Note
that, like [compare_length_with], this comparison does not explore the
list [l] beyond its [n]-th element. *)val(<):'alist->int->bool(** [Compare.List_length_with.(l <= n)] iff [l] is of length less than [n]. In
other words iff [Stdlib.List.compare_length_with l n <= 0]. Note that,
like [compare_length_with], this comparison does not explore the list [l]
beyond its [n]-th element. *)val(<=):'alist->int->bool(** [Compare.List_length_with.(l >= n)] iff [l] is of length greater than [n].
In other words iff [Stdlib.List.compare_length_with l n >= 0]. Note that,
like [compare_length_with], this comparison does not explore the list [l]
beyond its [n]-th element. *)val(>=):'alist->int->bool(** [Compare.List_length_with.(l > n)] iff [l] is of length strictly greater
than [n]. In other words iff [Stdlib.List.compare_length_with l n > 0].
Note that, like [compare_length_with], this comparison does not explore
the list [l] beyond its [n]-th element. *)val(>):'alist->int->bool(** [Compare.List_length_with.compare] is an alias for
[Stdlib.List.compare_length_with]. *)valcompare:'alist->int->int(** [Compare.List_length_with.equal] is an alias for
[Compare.List_length_with.( = )]. *)valequal:'alist->int->boolendmoduleList_lengths:sig(** [Compare.List_lengths.(xs = ys)] iff [xs] and [ys] have the same length.
In other words, iff [Stdlib.List.compare_lengths xs ys = 0]. Note that,
like [compare_lengths], this comparison only explores the lists up to the
length of the shortest one. *)val(=):'alist->'blist->bool(** [Compare.List_lengths.(xs <> ys)] iff [xs] and [ys] have different
lengths. In other words, iff [Stdlib.List.compare_lengths xs ys <> 0].
Note that, like [compare_lengths], this comparison only explores the lists
up to the length of the shortest one. *)val(<>):'alist->'blist->bool(** [Compare.List_lengths.(xs < ys)] iff [xs] is strictly shorter than [ys].
In other words, iff [Stdlib.List.compare_lengths xs ys < 0]. Note that,
like [compare_lengths], this comparison only explores the lists up to the
length of the shortest one. *)val(<):'alist->'blist->bool(** [Compare.List_lengths.(xs <= ys)] iff [xs] is shorter than [ys].
In other words, iff [Stdlib.List.compare_lengths xs ys <= 0]. Note that,
like [compare_lengths], this comparison only explores the lists up to the
length of the shortest one. *)val(<=):'alist->'blist->bool(** [Compare.List_lengths.(xs >= ys)] iff [xs] is longer than [ys].
In other words, iff [Stdlib.List.compare_lengths xs ys >= 0]. Note that,
like [compare_lengths], this comparison only explores the lists up to the
length of the shortest one. *)val(>=):'alist->'blist->bool(** [Compare.List_lengths.(xs > ys)] iff [xs] is strictly longer than [ys].
In other words, iff [Stdlib.List.compare_lengths xs ys > 0]. Note that,
like [compare_lengths], this comparison only explores the lists up to the
length of the shortest one. *)val(>):'alist->'blist->bool(** [Compare.List_lengths.compare] is an alias for
[Stdlib.List.compare_lengths]. *)valcompare:'alist->'blist->int(** [Compare.List_lengths.equal] is an alias for
[Compare.List_lengths.( = )]. *)valequal:'alist->'blist->boolend(** {2 Building blocks} *)(** [or_else c f] is [c] if [c <> 0] or [f ()] otherwise.
The intended use is
{[
let compare (foo_a, bar_a) (foo_b, bar_b) =
or_else (Foo.compare foo_a foo_b) (fun () -> Bar.compare bar_a bar_b)
]}
*)valor_else:int->(unit->int)->intend# 38 "v8.in.ml"moduleTime:sig# 1 "v8/time.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)typetincludeCompare.Swithtypet:=tvaladd:t->int64->tvaldiff:t->t->int64valof_seconds:int64->tvalto_seconds:t->int64valof_notation:string->toptionvalof_notation_exn:string->tvalto_notation:t->stringvalencoding:tData_encoding.tvalrfc_encoding:tData_encoding.tvalpp_hum:Format.formatter->t->unitend# 40 "v8.in.ml"moduleTzEndian:sig# 1 "v8/tzEndian.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2019 Nomadic Labs, <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)valget_int32:bytes->int->int32valget_int32_string:string->int->int32valset_int32:bytes->int->int32->unitvalset_int8:bytes->int->int->unitvalget_int8:bytes->int->intvalget_int8_string:string->int->intvalset_int16:bytes->int->int->unitvalget_int16:bytes->int->intvalget_int16_string:string->int->intvalset_int64:bytes->int->int64->unitvalget_int64:bytes->int->int64valget_int64_string:string->int->int64valget_uint8:bytes->int->intvalget_uint8_string:string->int->intvalset_uint8:bytes->int->int->unitvalget_uint16:bytes->int->intvalget_uint16_string:string->int->intvalset_uint16:bytes->int->int->unitend# 42 "v8.in.ml"moduleBits:sig# 1 "v8/bits.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2021 Nomadic Labs. <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Assuming [x >= 0], [numbits x] is the number of bits needed to
represent [x]. This is also the unique [k] such that
[2^{k - 1} <= x < 2^k] if [x > 0] and [0] otherwise.
The behaviour is unspecified if [x < 0].*)valnumbits:int->intend# 44 "v8.in.ml"moduleEquality_witness:sig# 1 "v8/equality_witness.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2021 Nomadic Labs. <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(**
This module provides support for type equalities and runtime type identifiers.
For two types [a] and [b], [(a, b) eq] is a witness that [a = b]. This is
a standard generalized algebraic datatype on top of which type-level
programming techniques can be implemented.
Given a type [a], an inhabitant of [a t] is a dynamic identifier for [a].
Identifiers can be compared for equality. They are also equipped with a
hash function.
WARNING: the hash function changes at every run. Therefore, the result
of the hash function should never be stored.
Notice that dynamic identifiers are not unique: two identifiers for [a]
can have distinct hash and can be physically distinct. Hence, only [eq]
can decide if two type identifiers correspond to the same type.
*)(** A proof witness that two types are equal. *)type(_,_)eq=Refl:('a,'a)eq(** A dynamic representation for ['a]. *)type'at(** [make ()] is a dynamic representation for ['a]. A fresh identifier
is returned each time [make ()] is evaluated. *)valmake:unit->'at(** [eq ida idb] returns a proof that [a = b] if [ida] and [idb]
identify the same type. *)valeq:'at->'bt->('a,'b)eqoption(** [hash id] returns a hash for [id]. *)valhash:'at->intend# 46 "v8.in.ml"moduleFallbackArray:sig# 1 "v8/fallbackArray.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2021 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(**
This module implements arrays equipped with accessors that cannot
raise exceptions. Reading out of the bounds of the arrays return a
fallback value fixed at array construction time, writing out of the
bounds of the arrays is ignored.
*)(** The type for array containing values of type ['a]. *)type'at(** [make len v] builds an array [a] initialized [len] cells with
[v]. The value [v] is the fallback value for [a]. *)valmake:int->'a->'at(** [of_list ~fallback ~proj l] builds a fallback array [a] of length
[List.length l] where each cell [i] is initialized by [proj (List.nth l i)]
and the fallback value is [fallback]. *)valof_list:fallback:'b->proj:('a->'b)->'alist->'bt(** [fallback a] returns the fallback value for [a]. *)valfallback:'at->'a(** [length a] returns the length of [a]. *)vallength:'at->int(** [get a idx] returns the contents of the cell of index [idx] in
[a]. If [idx] < 0 or [idx] >= [length a], [get a idx] =
[fallback a]. *)valget:'at->int->'a(** [set a idx value] updates the cell of index [idx] with [value].
If [idx] < 0 or [idx] >= [length a], [a] is unchanged. *)valset:'at->int->'a->unit(** [iter f a] iterates [f] over the cells of [a] from the
cell indexed [0] to the cell indexed [length a - 1]. *)valiter:('a->unit)->'at->unit(** [map f a] computes a new array obtained by applying [f] to each
cell contents of [a]. Notice that the fallback value of the new
array is [f (fallback a)]. *)valmap:('a->'b)->'at->'bt(** [fold f a init] traverses [a] from the cell indexed [0] to the
cell indexed [length a - 1] and transforms [accu] into [f accu x]
where [x] is the content of the cell under focus. [accu] is
[init] on the first iteration. *)valfold:('b->'a->'b)->'at->'b->'b(** [fold_map f a init fallback] traverses [a] from the cell indexed
[0] to the cell indexed [length a - 1] and transforms [accu] into
[fst (f accu x)] where [x] is the content of the cell under
focus. [accu] is [init] on the first iteration. The function also
returns a fresh array containing [snd (f accu x)] for each [x].
[fallback] is required to initialize a fresh array before it can be
filled. *)valfold_map:('b->'a->'b*'c)->'at->'b->'c->'b*'ctend# 48 "v8.in.ml"moduleError_monad:sig# 1 "v8/error_monad.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2020 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)typeerror_category=[`Branch|`Temporary|`Permanent|`Outdated](** CORE : errors *)typeerror=..valerror_encoding:errorData_encoding.tvalpp:Format.formatter->error->unit(** EXT : error registration/query *)valregister_error_kind:error_category->id:string->title:string->description:string->?pp:(Format.formatter->'err->unit)->'errData_encoding.t->(error->'erroption)->('err->error)->unitvaljson_of_error:error->Data_encoding.jsonvalerror_of_json:Data_encoding.json->errortypeerror_info={category:error_category;id:string;title:string;description:string;schema:Data_encoding.json_schema;}valpp_info:Format.formatter->error_info->unit(** Retrieves information of registered errors *)valget_registered_errors:unit->error_infolist(** MONAD : trace, monad, etc. *)type'errtracetype'atzresult=('a,errortrace)resultvalmake_trace_encoding:'errorData_encoding.t->'errortraceData_encoding.tvaltrace_encoding:errortraceData_encoding.tvalpp_trace:Format.formatter->errortrace->unitvalresult_encoding:'aData_encoding.t->'atzresultData_encoding.tvalok:'a->('a,'trace)resultvalreturn:'a->('a,'trace)resultLwt.tvalreturn_unit:(unit,'trace)resultLwt.tvalreturn_none:('aoption,'trace)resultLwt.tvalreturn_some:'a->('aoption,'trace)resultLwt.tvalreturn_nil:('alist,'trace)resultLwt.tvalreturn_true:(bool,'trace)resultLwt.tvalreturn_false:(bool,'trace)resultLwt.tvalerror:'err->('a,'errtrace)resultvaltrace_of_error:'err->'errtracevaltzfail:'err->('a,'errtrace)resultLwt.tval(>>=):'aLwt.t->('a->'bLwt.t)->'bLwt.tval(>|=):'aLwt.t->('a->'b)->'bLwt.tval(>>?):('a,'trace)result->('a->('b,'trace)result)->('b,'trace)resultval(>|?):('a,'trace)result->('a->'b)->('b,'trace)resultval(>>=?):('a,'trace)resultLwt.t->('a->('b,'trace)resultLwt.t)->('b,'trace)resultLwt.tval(>|=?):('a,'trace)resultLwt.t->('a->'b)->('b,'trace)resultLwt.tval(>>?=):('a,'trace)result->('a->('b,'trace)resultLwt.t)->('b,'trace)resultLwt.tval(>|?=):('a,'trace)result->('a->'bLwt.t)->('b,'trace)resultLwt.tvalrecord_trace:'err->('a,'errtrace)result->('a,'errtrace)resultvaltrace:'err->('b,'errtrace)resultLwt.t->('b,'errtrace)resultLwt.tvalrecord_trace_eval:(unit->'err)->('a,'errtrace)result->('a,'errtrace)resultvaltrace_eval:(unit->'err)->('b,'errtrace)resultLwt.t->('b,'errtrace)resultLwt.tvalerror_unless:bool->'err->(unit,'errtrace)resultvalerror_when:bool->'err->(unit,'errtrace)resultvalfail_unless:bool->'err->(unit,'errtrace)resultLwt.tvalfail_when:bool->'err->(unit,'errtrace)resultLwt.tvalunless:bool->(unit->(unit,'trace)resultLwt.t)->(unit,'trace)resultLwt.tvalwhen_:bool->(unit->(unit,'trace)resultLwt.t)->(unit,'trace)resultLwt.tvaldont_wait:(exn->unit)->('trace->unit)->(unit->(unit,'trace)resultLwt.t)->unit(** [catch f] executes [f] within a try-with block and wraps exceptions within
a [tzresult]. [catch f] is equivalent to
[try Ok (f ()) with e -> Error (error_of_exn e)].
If [catch_only] is set, then only exceptions [e] such that [catch_only e] is
[true] are caught.
Whether [catch_only] is set or not, this function never catches
non-deterministic runtime exceptions of OCaml such as {!Stack_overflow} and
{!Out_of_memory} nor system-exceptions such as {!Unix.Unix_error} and
{!Sys_error}. *)valcatch:?catch_only:(exn->bool)->(unit->'a)->'atzresult(** [catch_f f handler] is equivalent to [map_error (catch f) handler].
In other words, it catches exceptions in [f ()] and either returns the
value in an [Ok] or passes the exception to [handler] for the [Error].
[catch_only] has the same use as with [catch]. The same restriction on
catching non-deterministic runtime exceptions applies. *)valcatch_f:?catch_only:(exn->bool)->(unit->'a)->(exn->error)->'atzresult(** [catch_s] is like [catch] but when [f] returns a promise. It is equivalent
to
{[
Lwt.try_bind f
(fun v -> Lwt.return (Ok v))
(fun e -> Lwt.return (Error (error_of_exn e)))
]}
If [catch_only] is set, then only exceptions [e] such that [catch_only e] is
[true] are caught.
Whether [catch_only] is set or not, this function never catches
non-deterministic runtime exceptions of OCaml such as {!Stack_overflow} and
{!Out_of_memory} nor system-exceptions such as {!Unix.Unix_error} and
{!Sys_error}. *)valcatch_s:?catch_only:(exn->bool)->(unit->'aLwt.t)->'atzresultLwt.t(* Synchronisation *)valjoin_e:(unit,'errtrace)resultlist->(unit,'errtrace)resultvalall_e:('a,'errtrace)resultlist->('alist,'errtrace)resultvalboth_e:('a,'errtrace)result->('b,'errtrace)result->('a*'b,'errtrace)result(**/**)(* The protocol environment needs to know about shell's tzresult because they are
used for in-protocol RPCs. Moreover, some light processing on these results
is done in the protocol which requires the type to be concrete.
The type is kept private because the environment is sole responsible for
wrapping the protocol's errors into the shell's. *)typeshell_tztracetype'ashell_tzresult=('a,shell_tztrace)resultmoduleLwt_syntax:sigvalreturn:'a->'aLwt.tvalreturn_none:_optionLwt.tvalreturn_nil:_listLwt.tvalreturn_true:boolLwt.tvalreturn_false:boolLwt.tvalreturn_some:'a->'aoptionLwt.tvalreturn_ok:'a->('a,_)resultLwt.tvalreturn_error:'e->(_,'e)resultLwt.tvalreturn_ok_unit:(unit,'e)resultLwt.tvalreturn_ok_true:(bool,'e)resultLwt.tvalreturn_ok_false:(bool,'e)resultLwt.tvalreturn_ok_none:('aoption,'e)resultLwt.tvalreturn_ok_nil:('alist,'e)resultLwt.tval(let*):'aLwt.t->('a->'bLwt.t)->'bLwt.tval(and*):'aLwt.t->'bLwt.t->('a*'b)Lwt.tval(let+):'aLwt.t->('a->'b)->'bLwt.tval(and+):'aLwt.t->'bLwt.t->('a*'b)Lwt.tvaljoin:unitLwt.tlist->unitLwt.tvalall:'aLwt.tlist->'alistLwt.tvalboth:'aLwt.t->'bLwt.t->('a*'b)Lwt.tendmoduleOption_syntax:sigvalreturn:'a->'aoptionvalfail:'aoptionvalreturn_unit:unitoptionvalreturn_nil:'alistoptionvalreturn_true:booloptionvalreturn_false:booloptionval(let*):'aoption->('a->'boption)->'boptionval(and*):'aoption->'boption->('a*'b)optionval(let+):'aoption->('a->'b)->'boptionval(and+):'aoption->'boption->('a*'b)optionvalboth:'aoption->'boption->('a*'b)optionendmoduleResult_syntax:sigvalreturn:'a->('a,'e)resultvalreturn_unit:(unit,'e)resultvalreturn_none:('aoption,'e)resultvalreturn_some:'a->('aoption,'e)resultvalreturn_nil:('alist,'e)resultvalreturn_true:(bool,'e)resultvalreturn_false:(bool,'e)resultvalfail:'e->('a,'e)resultval(let*):('a,'e)result->('a->('b,'e)result)->('b,'e)resultval(let+):('a,'e)result->('a->'b)->('b,'e)resultvaljoin:(unit,'e)resultlist->(unit,'elist)resultvalall:('a,'e)resultlist->('alist,'elist)resultvalboth:('a,'e)result->('b,'e)result->('a*'b,'elist)resultvaltzfail:'error->('a,'errortrace)resultval(and*):('a,'etrace)result->('b,'etrace)result->('a*'b,'etrace)resultval(and+):('a,'etrace)result->('b,'etrace)result->('a*'b,'etrace)resultvaltzjoin:(unit,'errortrace)resultlist->(unit,'errortrace)resultvaltzall:('a,'errortrace)resultlist->('alist,'errortrace)resultvaltzboth:('a,'errortrace)result->('b,'errortrace)result->('a*'b,'errortrace)resultendmoduleLwt_result_syntax:sigvalreturn:'a->('a,'e)resultLwt.tvalreturn_unit:(unit,'e)resultLwt.tvalreturn_none:('aoption,'e)resultLwt.tvalreturn_some:'a->('aoption,'e)resultLwt.tvalreturn_nil:('alist,'e)resultLwt.tvalreturn_true:(bool,'e)resultLwt.tvalreturn_false:(bool,'e)resultLwt.tvalfail:'e->('a,'e)resultLwt.tval(let*):('a,'e)resultLwt.t->('a->('b,'e)resultLwt.t)->('b,'e)resultLwt.tval(let+):('a,'e)resultLwt.t->('a->'b)->('b,'e)resultLwt.tvallwt_map_error:('e->'f)->('a,'e)resultLwt.t->('a,'f)resultLwt.tval(let*!):'aLwt.t->('a->'bLwt.t)->'bLwt.tval(let*?):('a,'e)result->('a->('b,'e)resultLwt.t)->('b,'e)resultLwt.tvaljoin:(unit,'e)resultLwt.tlist->(unit,'elist)resultLwt.tvalall:('a,'e)resultLwt.tlist->('alist,'elist)resultLwt.tvalboth:('a,'e)resultLwt.t->('b,'e)resultLwt.t->('a*'b,'elist)resultLwt.tvaltzfail:'error->('a,'errortrace)resultLwt.tval(and*):('a,'etrace)resultLwt.t->('b,'etrace)resultLwt.t->('a*'b,'etrace)resultLwt.tval(and+):('a,'etrace)resultLwt.t->('b,'etrace)resultLwt.t->('a*'b,'etrace)resultLwt.tvaltzjoin:(unit,'errortrace)resultLwt.tlist->(unit,'errortrace)resultLwt.tvaltzall:('a,'errortrace)resultLwt.tlist->('alist,'errortrace)resultLwt.tvaltzboth:('a,'errortrace)resultLwt.t->('b,'errortrace)resultLwt.t->('a*'b,'errortrace)resultLwt.tendmoduleLwt_option_syntax:sigvalreturn:'a->'aoptionLwt.tvalreturn_unit:unitoptionLwt.tvalreturn_nil:'alistoptionLwt.tvalreturn_true:booloptionLwt.tvalreturn_false:booloptionLwt.tvalfail:'aoptionLwt.tval(let*):'aoptionLwt.t->('a->'boptionLwt.t)->'boptionLwt.tval(and*):'aoptionLwt.t->'boptionLwt.t->('a*'b)optionLwt.tval(let+):'aoptionLwt.t->('a->'b)->'boptionLwt.tval(and+):'aoptionLwt.t->'boptionLwt.t->('a*'b)optionLwt.tval(let*!):'aLwt.t->('a->'bLwt.t)->'bLwt.tval(let*?):'aoption->('a->'boptionLwt.t)->'boptionLwt.tvalboth:'aoptionLwt.t->'boptionLwt.t->('a*'b)optionLwt.tendend# 50 "v8.in.ml"openError_monadmoduleSeq:sig# 1 "v8/seq.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2020 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(* From Lwtreslib *)type'at=unit->'anodeand+'anode=Nil|Consof'a*'atvalempty:'atvalreturn:'a->'atvalcons:'a->'at->'atvalappend:'at->'at->'atvalmap:('a->'b)->'at->'btvalfilter:('a->bool)->'at->'atvalfilter_map:('a->'boption)->'at->'btvalflat_map:('a->'bt)->'at->'btvalfold_left:('a->'b->'a)->'a->'bt->'avaliter:('a->unit)->'at->unitvalunfold:('b->('a*'b)option)->'b->'at(** {3 Lwtreslib-specific extensions} *)(** [first s] is [None] if [s] is empty, it is [Some x] where [x] is the
first element of [s] otherwise.
Note that [first] forces the first element of the sequence, which can have
side-effects or be computationally expensive. Consider, e.g., the case
where [s = filter (fun …) s']: [first s] can force multiple of the values
from [s']. *)valfirst:'at->'aoption(** Similar to {!fold_left} but wraps the traversal in {!result}. The
traversal is interrupted if one of the step returns an [Error _]. *)valfold_left_e:('a->'b->('a,'trace)result)->'a->'bt->('a,'trace)result(** Similar to {!fold_left} but wraps the traversing in {!Lwt}. Each step of
the traversal is started after the previous one has resolved. The
traversal is interrupted if one of the promise is rejected. *)valfold_left_s:('a->'b->'aLwt.t)->'a->'bt->'aLwt.t(** Similar to {!fold_left} but wraps the traversing in [result Lwt.t].
Each step of the traversal is started after the previous one resolved. The
traversal is interrupted if one of the step is rejected or is fulfilled
with [Error _]. *)valfold_left_es:('a->'b->('a,'trace)resultLwt.t)->'a->'bt->('a,'trace)resultLwt.t(** Similar to {!iter} but wraps the iteration in {!result}. The iteration
is interrupted if one of the step returns an [Error _]. *)valiter_e:('a->(unit,'trace)result)->'at->(unit,'trace)result(** Similar to {!iter} but wraps the iteration in {!Lwt}. Each step
of the iteration is started after the previous one resolved. The iteration
is interrupted if one of the promise is rejected. *)valiter_s:('a->unitLwt.t)->'at->unitLwt.t(** Similar to {!iter} but wraps the iteration in [result Lwt.t]. Each step
of the iteration is started after the previous one resolved. The iteration
is interrupted if one of the promise is rejected of fulfilled with an
[Error _]. *)valiter_es:('a->(unit,'trace)resultLwt.t)->'at->(unit,'trace)resultLwt.t(** Similar to {!iter} but wraps the iteration in [result Lwt.t]. All the
steps of the iteration are started concurrently. The promise [iter_ep]
resolves once all the promises of the traversal resolve. At this point it
either:
- is rejected if at least one of the promises is, otherwise
- is fulfilled with [Error _] if at least one of the promises is,
otherwise
- is fulfilled with [Ok ()] if all the promises are. *)valiter_ep:('a->(unit,'errorError_monad.trace)resultLwt.t)->'at->(unit,'errorError_monad.trace)resultLwt.t(** Similar to {!iter} but wraps the iteration in {!Lwt}. All the
steps of the iteration are started concurrently. The promise [iter_p f s]
is resolved only once all the promises of the iteration are. At this point
it is either fulfilled if all promises are, or rejected if at least one of
them is. *)valiter_p:('a->unitLwt.t)->'at->unitLwt.tend# 54 "v8.in.ml"moduleList:sig# 1 "v8/list.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2020 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** {1 List}
A replacement for {!Stdlib.List} which:
- replaces the exception-raising functions by exception-safe variants,
- provides Lwt-, result- and Lwt-result-aware traversors.
[List] is intended to shadow both {!Stdlib.List} and {!Lwt_list}. *)(** {2 Basics}
Checkout {!Lwtreslib} for an introduction to the naming and semantic
convention of Lwtreslib. In a nutshell:
- Stdlib functions that raise exceptions are replaced by safe variants
(typically returning [option]).
- The [_e] suffix is for result-aware traversors ("e" stands for "error"),
[_s] and [_p] are for Lwt-aware, and [_es] and [_ep] are for
Lwt-result-aware.
- [_e], [_s], and [_es] traversors are {i fail-early}: they stop traversal
as soon as a failure ([Error] or [Fail]) occurs; [_p] and [_ep]
traversors are {i best-effort}: they only resolve once all of the
intermediate promises have, even if a failure occurs. *)(** {2 Double-traversal and combine}
Note that double-list traversors ([iter2], [map2], etc., and also [combine])
take an additional [when_different_lengths] parameter. This is to control
the error that is returned when the two lists passed as arguments have
different lengths.
This mechanism is a replacement for {!Stdlib.List.iter2} (etc.) raising
[Invalid_argument].
Note that, as per the fail-early behaviour mentioned above, [_e], [_s], and
[_es] traversors will have already processed the common-prefix before the
error is returned.
Because the best-effort behaviour of [_p] and [_ep] is unsatisfying for this
failure case, double parallel traversors are omitted from this library.
(Specifically, it is not obvious whether nor how the
[when_different_lengths] error should be composed with the other errors.)
To obtain a different behaviour for sequential traversors, or to process
two lists in parallel, you can use {!combine} or any of the alternatives
that handles the error differently: {!combine_drop},
{!combine_with_leftovers}. Finally, the {!rev_combine} is provided to allow
to avoid multiple-reversing.
{3 Special considerations}
Because they traverse the list from right-to-left, the {!fold_right2}
function and all its variants fail with [when_different_lengths] before any
of the processing starts. Whilst this is still within the fail-early
behaviour, it may be surprising enough that it requires mentioning here.
Because they may return early, {!for_all2} and {!exists2} and all their
variants may return [Ok _] even though the arguments have different lengths.
*)(** {2 API} *)(** {3 The list type} *)type'at='alist=[]|(::)of'a*'alist(** {3 Constructors and some such} *)(** [nil] is [[]] *)valnil:'alist(** [nil_e] is [Ok []] *)valnil_e:('alist,'trace)result(** [nil_s] is [Lwt.return_nil] *)valnil_s:'alistLwt.t(** [nil_es] is [Lwt.return (Ok [])] *)valnil_es:('alist,'trace)resultLwt.t(** [cons x xs] is [x :: xs] *)valcons:'a->'alist->'alist(** [is_empty xs] is [true] iff [xs] is [[]] *)valis_empty:'alist->bool(** {3 Safe wrappers}
This part of the module simply shadows some functions from {!Stdlib.List}
with exceptionless variants. As per the design principles of Lwtreslib,
- functions which may fail with [Not_found] or otherwise from
unavailability of data return an [option] instead,
- function which may fail with [Invalid_argument _] or otherwise from
malformedness of input receive an additional parameter to return as an
[Error] instead,
- functions which perform polymorphic comparison receive an additional
parameter for monomorphic comparison instead. *)(** [hd xs] is the head (first element) of the list or [None] if the list is
empty. *)valhd:'alist->'aoption(** [tl xs] is the tail of the list (the whole list except the first element)
or [None] if the list is empty. *)valtl:'alist->'alistoption(** [nth xs n] is the [n]th element of the list or [None] if the list has
fewer than [n] elements.
For example, [nth xs 0 = hd xs] and [nth ['x'; 'y'] 1 = Some 'y']. *)valnth:'alist->int->'aoption(** [nth_opt] is an alias for [nth] provided for compatibility with
{!Stdlib.List}. *)valnth_opt:'alist->int->'aoption(** [last x xs] is the last element of the list [xs] or [x] if [xs] is empty.
The primary intended use for [last] is after destructing a list:
[match l with | [] -> … | x :: xs -> last x xs]
but it can also be used for a default value:
[last default_value_if_empty xs]. *)vallast:'a->'alist->'a(** [last_opt xs] is the last element of the list [xs] or [None] if the list
[xs] is empty. *)vallast_opt:'alist->'aoption(** [find predicate xs] is the first element [x] of the list [xs] such that
[predicate x] is [true] or [None] if the list [xs] has no such element. *)valfind:('a->bool)->'alist->'aoption(** [find_opt] is an alias for [find] provided for compatibility with
{!Stdlib.List}. *)valfind_opt:('a->bool)->'alist->'aoption(** [find_map f xs] applies [f] to each of the elements of [xs] until it
returns [Some _] at which point it is returned. If no such elements are
found then it returns [None].
Note that it only applies [f] to a prefix of [xs]. It doesn't apply [f] to
the elements of [xs] which are after the found element. Consequently,
[find_map f xs] has better performance and a different semantic than
calling [map] and [find] separately. *)valfind_map:('a->'boption)->'alist->'boption(** [mem ~equal a l] is [true] iff there is an element [e] of [l] such that
[equal a e]. *)valmem:equal:('a->'a->bool)->'a->'alist->bool(** [assoc ~equal k kvs] is [Some v] such that [(k', v)] is the first pair in
the list such that [equal k' k] or [None] if the list contains no such
pair. *)valassoc:equal:('a->'a->bool)->'a->('a*'b)list->'boption(** [assoc_opt] is an alias for [assoc] provided for compatibility with
{!Stdlib.List}. *)valassoc_opt:equal:('a->'a->bool)->'a->('a*'b)list->'boption(** [assq k kvs] is the same as [assoc ~equal:Stdlib.( == ) k kvs]: it uses
the physical equality. *)valassq:'a->('a*'b)list->'boption(** [assq_opt] is an alias for [assq] provided for compatibility with
{!Stdlib.List}. *)valassq_opt:'a->('a*'b)list->'boption(** [mem_assoc ~equal k l] is equivalent to
[Option.is_some @@ assoc ~equal k l]. *)valmem_assoc:equal:('a->'a->bool)->'a->('a*'b)list->bool(** [mem_assq k l] is [mem_assoc ~equal:Stdlib.( == ) k l]. *)valmem_assq:'a->('a*'b)list->bool(** [remove_assoc ~equal k l] is [l] without the first element [(k', _)] such
that [equal k k']. *)valremove_assoc:equal:('a->'a->bool)->'a->('a*'b)list->('a*'b)list(** [remove_assoq k l] is [remove_assoc ~equal:Stdlib.( == ) k l]. *)valremove_assq:'a->('a*'b)list->('a*'b)list(** {3 Initialisation} *)(** [init ~when_negative_length n f] is a list of [n] elements [f 0], [f 1],
etc.
If [n] is negative, it is [Error when_negative_length] instead. *)valinit:when_negative_length:'trace->int->(int->'a)->('alist,'trace)result(** {3 Basic traversal} *)(** [length xs] is the number of elements in [xs].
[length []] is [0], [length ['x']] is [1], etc. *)vallength:'alist->int(** [rev xs] is a list with the elements appearing in the reverse order as in
[xs].
[rev ['x'; 'y']] is ['y'; 'x'] *)valrev:'alist->'alist(** [concat xs] is a list containing the elements of the elements of [xs].
[concat [['x'; 'y']; ['a'; 'b']]] is [['x'; 'y'; 'a'; 'b']] *)valconcat:'alistlist->'alist(** [append xs ys] is a list containing the elements of [xs] and the elements
of [ys], in this order.
[concat ['x'; 'y'] ['a'; 'b']] is [['x'; 'y'; 'a'; 'b']] *)valappend:'alist->'alist->'alist(** [rev_append xs ys] is [append (rev xs) ys] but more efficient. In other
words, [rev_append xs ys] is a list containing the elements of xs in
reverse order followed by the elements of [ys].
There are two main use-cases for [rev_append]. First, you should use
[rev_append] when the order of elements is unimportant. In this case you
simply replace [append xs ys] with [rev_append xs ys].
Second, you can use [rev_append] on an already reversed list. You may
obtain an already reversed list from any of the other [rev_*] functions of
this module, or simply via your own traversal. In this case, you replace,
say, [append (map f xs) ys] with [rev_append (rev_map f xs) ys]. *)valrev_append:'alist->'alist->'alist(** [flatten] is an alias for {!concat}. *)valflatten:'alistlist->'alist(** {3 Double-list traversals}
These safe-wrappers take an explicit value to handle the case of lists of
unequal length. This value is passed as a named parameter:
[when_different_lengths].
Note that the traversal function passed as argument (if any) is applied to
the common prefix of the two lists, even if they are of different lengths.
E.g., in [map2 f ['x', 'y'] ['a']] the call [f 'x' 'a'] is made and all
its side-effects are performed before the value
[Error when_different_lengths] is returned
*)(** [combine ~when_different_lengths l1 l2] is either
- [Error when_different_lengths] if [List.length l1 <> List.length l2]
- a list of pairs of elements from [l1] and [l2]
E.g., [combine ~when_different_lengths [] []] is [Ok []]
E.g., [combine ~when_different_lengths [1; 2] ['a'; 'b']] is [Ok [(1,'a'); (2, 'b')]]
E.g., [combine ~when_different_lengths:"wrong" [1] []] is [Error "wrong"]
Note: [combine ~when_different_lengths l1 l2] is equivalent to
[try Ok (Stdlib.List.combine l1 l2) with Invalid_argument _ -> when_different_lengths]
The same equivalence almost holds for the other double traversors below.
The notable difference is if the functions passed as argument to the
traversors raise the [Invalid_argument _] exception. *)valcombine:when_different_lengths:'trace->'alist->'blist->(('a*'b)list,'trace)result(** [rev_combine ~when_different_lengths xs ys] is
[rev (combine ~when_different_lengths xs ys)] but more efficient. *)valrev_combine:when_different_lengths:'trace->'alist->'blist->(('a*'b)list,'trace)result(** [split xs] is [(List.map fst xs, List.map snd xs)] but more efficient. *)valsplit:('a*'b)list->'alist*'blist(** [iter2 ~when_different_lengths f xs ys] is [f x0 y0; f x1 y1; …].
Remember that, even if the lists are of different lengths, the function
[f] is applied to the common prefix of [xs] and [ys]. This is true for
other traversals, but especially relevant to [iter] which is commonly used
for side-effects. *)valiter2:when_different_lengths:'trace->('a->'b->unit)->'alist->'blist->(unit,'trace)result(** [map2 ~when_different_lengths f xs ys] is a list with elements [f x0 y0],
[f x1 y1], etc.
Remember that, even if the lists are of different lengths, the function
[f] is applied to the common prefix of [xs] and [ys]. Beware of
side-effects and computational cost. *)valmap2:when_different_lengths:'trace->('a->'b->'c)->'alist->'blist->('clist,'trace)result(** [rev_map2 ~when_different_lengths f xs ys] is
[Result.map rev @@ map2 ~when_different_lengths f xs ys] but more
efficient.
Remember that, even if the lists are of different lengths, the function
[f] is applied to the common prefix of [xs] and [ys]. Beware of
side-effects and computational cost. *)valrev_map2:when_different_lengths:'trace->('a->'b->'c)->'alist->'blist->('clist,'trace)result(** [fold_left2 ~when_different_lengths f init xs ys] is
[… (f (f init x0 y0) x1 y1)].
Remember that, even if the lists are of different lengths, the function
[f] is applied to the common prefix of [xs] and [ys]. Beware of
side-effects and computational cost. *)valfold_left2:when_different_lengths:'trace->('a->'b->'c->'a)->'a->'blist->'clist->('a,'trace)result(** [fold_right2 ~when_different_lengths f xs ys init] is
[f x0 y0 (f x1 y1 (…))].
This function is not tail-recursive.
Note that unlike the left-to-right double-list traversors, [fold_right2]
only calls [f] if the lists are of the same length. *)valfold_right2:when_different_lengths:'trace->('a->'b->'c->'c)->'alist->'blist->'c->('c,'trace)result(** [for_all2 ~when_different_lengths f xs ys] is
[f x0 y0 && f x1 y1 && …].
The function stops early if it encounters elements [xn], [yn] such that [f
xn yn] is [false]. (This is consistent with the short-circuit, lazy
evaluation strategy of [&&] in the description above.)
Also note that, if such an element is found in the common prefix of [xs]
and [ys], then the function returns [Ok false] even if [xs] and [ys] are
of different lengths.
Examples:
[for_all2 ~when_different_lengths (=) [] []] is [Ok true]
[for_all2 ~when_different_lengths (=) ['x'] ['a']] is [Ok false]
[for_all2 ~when_different_lengths (=) ['x'; 'y'] ['a']] is [Ok false]
[for_all2 ~when_different_lengths (=) ['x'] ['x']] is [Ok true]
[for_all2 ~when_different_lengths (=) ['x'; 'y'] ['x']] is [Error when_different_lengths]
[for_all2 ~when_different_lengths (=) ['x'; 'y'] ['x'; 'b']] is [Ok false]
[for_all2 ~when_different_lengths (=) ['x'; 'y'] ['x'; 'y'; 'c']] is
[Error when_different_lengths]
Remember that, when it returns [Error when_different_lengths], the
function [f] has already been applied to the common prefix of [xs] and
[ys]. Beware of side-effects and computational cost. *)valfor_all2:when_different_lengths:'trace->('a->'b->bool)->'alist->'blist->(bool,'trace)result(** [exists2 ~when_different_lengths f xs ys] is
[f x0 y0 || f x1 y1 || …].
The function stops early if it encounters elements [xn], [yn] such that [f
xn yn] is [true]. (This is consistent with the short-circuit, lazy
evaluation strategy of [||] in the description above.)
Also note that, if such an element is found in the common prefix of [xs]
and [ys], then the function returns [Ok true] even if [xs] and [ys] are of
different lengths.
Examples:
[exists2 ~when_different_lengths (=) [] []] is [Ok false]
[exists2 ~when_different_lengths (=) ['x'] ['a']] is [Ok false]
[exists2 ~when_different_lengths (=) ['x'; 'y'] ['a']] is [Error when_different_lengths]
[exists2 ~when_different_lengths (=) ['x'] ['x']] is [Ok true]
[exists2 ~when_different_lengths (=) ['x'; 'y'] ['x']] is [Ok true]
Remember that, when it returns [Error when_different_lengths], the
function [f] has already been applied to the common prefix of [xs] and
[ys]. Beware of side-effects and computational cost. *)valexists2:when_different_lengths:'trace->('a->'b->bool)->'alist->'blist->(bool,'trace)result(** {3 Monad-aware variants}
The functions below are strict extensions of the standard {!Stdlib.List}
module. It is for result-, lwt- and lwt-result-aware variants. The meaning
of the suffix is as described above, in {!Lwtreslib}, and in {!Sigs.Seq}. *)(** {3 Initialisation variants}
Note that for asynchronous variants ([_s], [_es], [_p], and [_ep]), if the
length parameter is negative, then the promise is returned already
fulfilled with [Error when_different_lengths]. *)(** [init_e] is a Result-aware variant of {!init}. *)valinit_e:when_negative_length:'trace->int->(int->('a,'trace)result)->('alist,'trace)result(** [init_s] is an Lwt-aware variant of {!init}. *)valinit_s:when_negative_length:'trace->int->(int->'aLwt.t)->('alist,'trace)resultLwt.t(** [init_es] is an Lwt-Result-aware variant of {!init}. *)valinit_es:when_negative_length:'trace->int->(int->('a,'trace)resultLwt.t)->('alist,'trace)resultLwt.t(** [init_p] is a variant of {!init_s} where the promises are evaluated
concurrently. *)valinit_p:when_negative_length:'trace->int->(int->'aLwt.t)->('alist,'trace)resultLwt.t(** {3 Query variants} *)(** [find_e] is a Result-aware variant of {!find}. *)valfind_e:('a->(bool,'trace)result)->'alist->('aoption,'trace)result(** [find_s] is an Lwt-aware variant of {!find}. *)valfind_s:('a->boolLwt.t)->'alist->'aoptionLwt.t(** [find_es] is an Lwt-Result-aware variant of {!find}. *)valfind_es:('a->(bool,'trace)resultLwt.t)->'alist->('aoption,'trace)resultLwt.t(** [find_map_e] is a Result-aware variant of {!find_map}. *)valfind_map_e:('a->('boption,'trace)result)->'alist->('boption,'trace)result(** [find_map_s] is an Lwt-aware variant of {!find_map}. *)valfind_map_s:('a->'boptionLwt.t)->'alist->'boptionLwt.t(** [find_map_es] is an Lwt-Result-aware variant of {!find_map}. *)valfind_map_es:('a->('boption,'trace)resultLwt.t)->'alist->('boption,'trace)resultLwt.t(** [filter f xs] is the list of all the elements [xn] of [xs] such that
[f xn] is [true].
[filter (fun x -> x > 10) [0; 2; 19; 22; -1; 3; 11]] is [[19; 22; 11]] *)valfilter:('a->bool)->'alist->'alist(** [filteri] is similar to {!filter} but the predicate also receives the
element's index as an argument. *)valfilteri:(int->'a->bool)->'alist->'alist(** [find_all] is an alias for {!filter}. *)valfind_all:('a->bool)->'alist->'alist(** [rev_filter f l] is [rev (filter f l)] but more efficient. *)valrev_filter:('a->bool)->'alist->'alist(** [rev_filteri f l] is [rev (filteri f l)] but more efficient. *)valrev_filteri:(int->'a->bool)->'alist->'alist(** [rev_filter_some xs] is [rev @@ filter_some xs] but more efficient. *)valrev_filter_some:'aoptionlist->'alist(** [filter_some] extracts all the payloads of the [Some] variants.
The order is preserved.
[filter_some [None; Some 'a'; None; None; Some 'z'; Some 'u']] is
[['a'; 'z'; 'u']]. *)valfilter_some:'aoptionlist->'alist(** [rev_filter_ok rs] is [rev @@ filter_ok rs] but more efficient. *)valrev_filter_ok:('a,'b)resultlist->'alist(** [filter_ok] extracts all the payloads of the [Ok] variants.
The order is preserved.
[filter_ok [Error 3; Ok 'a'; Error 3; Error 5; Ok 'z'; Ok 'u']] is
[['a'; 'z'; 'u']]. *)valfilter_ok:('a,'b)resultlist->'alist(** [rev_filter_error rs] is [rev @@ filter_error rs] but more efficient. *)valrev_filter_error:('a,'b)resultlist->'blist(** [filter_error] extracts all the payloads of the [Error] variants.
The order is preserved.
[filter_ok [Error 3; Ok 'a'; Error 3; Error 5; Ok 'z'; Ok 'u']] is
[[3; 3; 5]]. *)valfilter_error:('a,'b)resultlist->'blist(** [rev_filter_left es] is [rev @@ filter_left es] but more efficient. *)valrev_filter_left:('a,'b)Either.tlist->'alist(** [filter_left] extracts all the payloads of the [Left] variants.
The order is preserved.
[filter_left [Right 3; Left 'a'; Right 3; Right 5; Left 'z'; Left 'u']] is
[['a'; 'z'; 'u']]. *)valfilter_left:('a,'b)Either.tlist->'alist(** [rev_filter_right es] is [rev @@ filter_right es] but more efficient. *)valrev_filter_right:('a,'b)Either.tlist->'blist(** [filter_right] extracts all the payloads of the [Right] variants.
The order is preserved.
[filter_right [Right 3; Left 'a'; Right 3; Right 5; Left 'z'; Left 'u']] is
[[3; 3; 5]]. *)valfilter_right:('a,'b)Either.tlist->'blist(** [rev_filter_e] is a Result-aware variant of {!rev_filter}. *)valrev_filter_e:('a->(bool,'trace)result)->'alist->('alist,'trace)result(** [filter_e] is a Result-aware variant of {!filter}. *)valfilter_e:('a->(bool,'trace)result)->'alist->('alist,'trace)result(** [rev_filter_s] is an Lwt-aware variant of {!rev_filter}. *)valrev_filter_s:('a->boolLwt.t)->'alist->'alistLwt.t(** [filter_s] is an Lwt-aware variant of {!filter}. *)valfilter_s:('a->boolLwt.t)->'alist->'alistLwt.t(** [rev_filter_es] is an Lwt-Result-aware variant of {!rev_filter}. *)valrev_filter_es:('a->(bool,'trace)resultLwt.t)->'alist->('alist,'trace)resultLwt.t(** [filter_es] is an Lwt-Result-aware variant of {!filter}. *)valfilter_es:('a->(bool,'trace)resultLwt.t)->'alist->('alist,'trace)resultLwt.t(** [rev_filteri_e] is a Result-aware variant of {!rev_filteri}. *)valrev_filteri_e:(int->'a->(bool,'trace)result)->'alist->('alist,'trace)result(** [filteri_e] is a Result-aware variant of {!filteri}. *)valfilteri_e:(int->'a->(bool,'trace)result)->'alist->('alist,'trace)result(** [rev_filteri_s] is an Lwt-aware variant of {!rev_filteri}. *)valrev_filteri_s:(int->'a->boolLwt.t)->'alist->'alistLwt.t(** [filteri_s] is an Lwt-aware variant of {!filteri}. *)valfilteri_s:(int->'a->boolLwt.t)->'alist->'alistLwt.t(** [rev_filteri_es] is an Lwt-Result-aware variant of {!rev_filteri}. *)valrev_filteri_es:(int->'a->(bool,'trace)resultLwt.t)->'alist->('alist,'trace)resultLwt.t(** [filteri_es] is an Lwt-Result-aware variant of {!filteri}. *)valfilteri_es:(int->'a->(bool,'trace)resultLwt.t)->'alist->('alist,'trace)resultLwt.t(** [rev_partition f xs] is [let rt, rf = partition f xs in (rev rt, rev rf)]
but more efficient. *)valrev_partition:('a->bool)->'alist->'alist*'alist(** [partition f xs] is a couple of lists [(ts, fs)] where [ts] contains all
the elements of [xs] such that [f x] is [true] and [fs] contains all the
elements of [xs] such that [f x] is [false].
The function [f] is applied once to each element of [xs]. *)valpartition:('a->bool)->'alist->'alist*'alist(** [rev_partition_map f xs] is
[let rt, rf = partition_map f xs in (rev rt, rev rf)]
but more efficient. *)valrev_partition_map:('a->('b,'c)Either.t)->'alist->'blist*'clist(** [partition_map f xs] applies [f] to each of the element of [xs] and
returns a couple of lists [(ls, rs)] where [ls] contains all
the [l] such that [f x] is [Left l] and [rs] contains all
the [r] such that [f x] is [Right r]. *)valpartition_map:('a->('b,'c)Either.t)->'alist->'blist*'clist(** [rev_partition_result rs] is [partition_result @@ rev rs] but more
efficient. *)valrev_partition_result:('a,'b)resultlist->'alist*'blist(** [partition_result rs] is a tuple of lists [(os, es)] where [os] contains
all the payloads of [Ok] variants of [rs] and [es] contains all the
payloads of [Error] variants of [rs].
[partition_result rs] is [(filter_ok rs, filter_error rs)] but more
efficient. *)valpartition_result:('a,'b)resultlist->'alist*'blist(** [rev_partition_either rs] is [partition_either @@ rev rs] but more
efficient. *)valrev_partition_either:('a,'b)Either.tlist->'alist*'blist(** [partition_either es] is a tuple of lists [(ls, rs)] where [ls] contains
all the payloads of [Left] variants of [ls] and [rs] contains all the
payloads of [Right] variants of [es].
[partition_either es] is [(filter_left es, filter_right es)] but more
efficient. *)valpartition_either:('a,'b)Either.tlist->'alist*'blist(** [rev_partition_e] is a Result-aware variant of {!rev_partition}. *)valrev_partition_e:('a->(bool,'trace)result)->'alist->('alist*'alist,'trace)result(** [partition_e] is a Result-aware variant of {!partition}. *)valpartition_e:('a->(bool,'trace)result)->'alist->('alist*'alist,'trace)result(** [rev_partition_s] is an Lwt-aware variant of {!rev_partition}. *)valrev_partition_s:('a->boolLwt.t)->'alist->('alist*'alist)Lwt.t(** [partition_s] is an Lwt-aware variant of {!partition}. *)valpartition_s:('a->boolLwt.t)->'alist->('alist*'alist)Lwt.t(** [rev_partition_es] is an Lwt-Result-aware variant of {!rev_partition}. *)valrev_partition_es:('a->(bool,'trace)resultLwt.t)->'alist->('alist*'alist,'trace)resultLwt.t(** [partition_es] is an Lwt-Result-aware variant of {!partition}. *)valpartition_es:('a->(bool,'trace)resultLwt.t)->'alist->('alist*'alist,'trace)resultLwt.t(** [partition_p] is a variant of {!partition_s} where the promises are
evaluated concurrently. *)valpartition_p:('a->boolLwt.t)->'alist->('alist*'alist)Lwt.t(** [rev_partition_map_e] is a Result-aware variant of {!rev_partition_map}. *)valrev_partition_map_e:('a->(('b,'c)Either.t,'trace)result)->'alist->('blist*'clist,'trace)result(** [partition_map_e] is a Result-aware variant of {!partition_map}. *)valpartition_map_e:('a->(('b,'c)Either.t,'trace)result)->'alist->('blist*'clist,'trace)result(** [rev_partition_map_s] is an Lwt-aware variant of {!rev_partition_map}. *)valrev_partition_map_s:('a->('b,'c)Either.tLwt.t)->'alist->('blist*'clist)Lwt.t(** [partition_map_s] is an Lwt-aware variant of {!partition_map}. *)valpartition_map_s:('a->('b,'c)Either.tLwt.t)->'alist->('blist*'clist)Lwt.t(** [rev_partition_map_es] is an Lwt-Result-aware variant of
{!rev_partition_map}. *)valrev_partition_map_es:('a->(('b,'c)Either.t,'trace)resultLwt.t)->'alist->('blist*'clist,'trace)resultLwt.t(** [partition_map_es] is an Lwt-Result-aware variant of {!partition_map}. *)valpartition_map_es:('a->(('b,'c)Either.t,'trace)resultLwt.t)->'alist->('blist*'clist,'trace)resultLwt.t(** {3 Traversal variants} *)(** [iter f xs] is [f x0; f x1; …]. *)valiter:('a->unit)->'alist->unit(** [iter_e] is a Result-aware variant of {!iter}. *)valiter_e:('a->(unit,'trace)result)->'alist->(unit,'trace)result(** [iter_s] is an Lwt-aware variant of {!iter}. *)valiter_s:('a->unitLwt.t)->'alist->unitLwt.t(** [iter_es] is an Lwt-Result-aware variant of {!iter}. *)valiter_es:('a->(unit,'trace)resultLwt.t)->'alist->(unit,'trace)resultLwt.t(** [iter_p] is a variant of {!iter_s} where the promises are evaluated
concurrently. *)valiter_p:('a->unitLwt.t)->'alist->unitLwt.t(** [iteri f xs] is [f 0 x0; f 1 x1; …]. *)valiteri:(int->'a->unit)->'alist->unit(** [iteri_e] is a Result-aware variant of {!iteri}. *)valiteri_e:(int->'a->(unit,'trace)result)->'alist->(unit,'trace)result(** [iteri_s] is an Lwt-aware variant of {!iteri}. *)valiteri_s:(int->'a->unitLwt.t)->'alist->unitLwt.t(** [iteri_es] is an Lwt-Result-aware variant of {!iteri}. *)valiteri_es:(int->'a->(unit,'trace)resultLwt.t)->'alist->(unit,'trace)resultLwt.t(** [iteri_p] is a variant of {!iteri_s} where the promises are evaluated
concurrently. *)valiteri_p:(int->'a->unitLwt.t)->'alist->unitLwt.t(** [map f xs] is the list [[f x0; f x1; …]]. *)valmap:('a->'b)->'alist->'blist(** [map_e] is a Result-aware variant of {!map}. *)valmap_e:('a->('b,'trace)result)->'alist->('blist,'trace)result(** [map_s] is an Lwt-aware variant of {!map}. *)valmap_s:('a->'bLwt.t)->'alist->'blistLwt.t(** [map_es] is an Lwt-Result-aware variant of {!map}. *)valmap_es:('a->('b,'trace)resultLwt.t)->'alist->('blist,'trace)resultLwt.t(** [map_p] is a variant of {!map_s} where the promises are evaluated
concurrently. *)valmap_p:('a->'bLwt.t)->'alist->'blistLwt.t(** [mapi f xs] is the list [[f 0 x0; f 1 x1; …]]. *)valmapi:(int->'a->'b)->'alist->'blist(** [mapi_e] is a Result-aware variant of {!mapi}. *)valmapi_e:(int->'a->('b,'trace)result)->'alist->('blist,'trace)result(** [mapi_s] is an Lwt-aware variant of {!mapi}. *)valmapi_s:(int->'a->'bLwt.t)->'alist->'blistLwt.t(** [mapi_es] is an Lwt-Result-aware variant of {!mapi}. *)valmapi_es:(int->'a->('b,'trace)resultLwt.t)->'alist->('blist,'trace)resultLwt.t(** [mapi_p] is a variant of {!mapi_s} where the promises are evaluated
concurrently. *)valmapi_p:(int->'a->'bLwt.t)->'alist->'blistLwt.t(** [rev_map f xs] is [rev @@ map f xs] but more efficient. *)valrev_map:('a->'b)->'alist->'blist(** [rev_mapi f xs] is [rev @@ mapi f xs] but more efficient. *)valrev_mapi:(int->'a->'b)->'alist->'blist(** [rev_map_e] is a Result-aware variant of {!rev_map}. *)valrev_map_e:('a->('b,'trace)result)->'alist->('blist,'trace)result(** [rev_map_s] is an Lwt-aware variant of {!rev_map}. *)valrev_map_s:('a->'bLwt.t)->'alist->'blistLwt.t(** [rev_map_es] is an Lwt-Result-aware variant of {!rev_map}. *)valrev_map_es:('a->('b,'trace)resultLwt.t)->'alist->('blist,'trace)resultLwt.t(** [rev_map_p] is a variant of {!rev_map_s} where the promises are evaluated
concurrently. *)valrev_map_p:('a->'bLwt.t)->'alist->'blistLwt.t(** [rev_mapi_e] is a Result-aware variant of {!rev_mapi}. *)valrev_mapi_e:(int->'a->('b,'trace)result)->'alist->('blist,'trace)result(** [rev_mapi_s] is an Lwt-aware variant of {!rev_mapi}. *)valrev_mapi_s:(int->'a->'bLwt.t)->'alist->'blistLwt.t(** [rev_mapi_es] is an Lwt-Result-aware variant of {!rev_mapi}. *)valrev_mapi_es:(int->'a->('b,'trace)resultLwt.t)->'alist->('blist,'trace)resultLwt.t(** [rev_mapi_p] is a variant of {!rev_mapi_s} where the promises are
evaluated concurrently. *)valrev_mapi_p:(int->'a->'bLwt.t)->'alist->'blistLwt.t(** [rev_filter_map f xs] is [rev @@ filter_map f xs] but more efficient. *)valrev_filter_map:('a->'boption)->'alist->'blist(** [rev_filter_map_e] is a Result-aware variant of {!rev_filter_map}. *)valrev_filter_map_e:('a->('boption,'trace)result)->'alist->('blist,'trace)result(** [filter_map_e] is a Result-aware variant of {!filter_map}. *)valfilter_map_e:('a->('boption,'trace)result)->'alist->('blist,'trace)result(** [rev_filter_map_s] is an Lwt-aware variant of {!rev_filter_map}. *)valrev_filter_map_s:('a->'boptionLwt.t)->'alist->'blistLwt.t(** [filter_map f xs] is [filter_some @@ map f xs] but more efficient. *)valfilter_map:('a->'boption)->'alist->'blist(** [filter_map_s] is an Lwt-aware variant of {!filter_map}. *)valfilter_map_s:('a->'boptionLwt.t)->'alist->'blistLwt.t(** [rev_filter_map_es] is an Lwt-Result-aware variant of {!rev_filter_map}. *)valrev_filter_map_es:('a->('boption,'trace)resultLwt.t)->'alist->('blist,'trace)resultLwt.t(** [filter_map_es] is an Lwt-Result-aware variant of {!filter_map}. *)valfilter_map_es:('a->('boption,'trace)resultLwt.t)->'alist->('blist,'trace)resultLwt.t(** [filter_map_p] is a variant of {!filter_map_s} where the promises are evaluated concurrently. *)valfilter_map_p:('a->'boptionLwt.t)->'alist->'blistLwt.t(** [concat_map f xs] is [concat (map f xs)] but more efficient. *)valconcat_map:('a->'blist)->'alist->'blist(** [concat_map_s] is an Lwt-aware variant of {!concat_map}. *)valconcat_map_s:('a->'blistLwt.t)->'alist->'blistLwt.t(** [concat_map_e] is a Result-aware variant of {!concat_map}. *)valconcat_map_e:('a->('blist,'error)result)->'alist->('blist,'error)result(** [concat_map_es] is an Lwt-Result-aware variant of {!concat_map}. *)valconcat_map_es:('a->('blist,'error)resultLwt.t)->'alist->('blist,'error)resultLwt.t(** [concat_map_p] is a variant of {!concat_map_s} where the promises are evaluated concurrently. *)valconcat_map_p:('a->'blistLwt.t)->'alist->'blistLwt.tvalfold_left:('a->'b->'a)->'a->'blist->'a(** [fold_left_e] is a Result-aware variant of {!fold_left}. *)valfold_left_e:('a->'b->('a,'trace)result)->'a->'blist->('a,'trace)result(** [fold_left_s] is an Lwt-aware variant of {!fold_left}. *)valfold_left_s:('a->'b->'aLwt.t)->'a->'blist->'aLwt.t(** [fold_left_es] is an Lwt-Result-aware variant of {!fold_left}. *)valfold_left_es:('a->'b->('a,'trace)resultLwt.t)->'a->'blist->('a,'trace)resultLwt.t(** [fold_left_map f a xs] is a combination of [fold_left] and [map] that maps
over all elements of [xs] and threads an accumulator with initial value [a]
through calls to [f]. *)valfold_left_map:('a->'b->'a*'c)->'a->'blist->'a*'clist(** [fold_left_map_e f a xs] is a combination of [fold_left_e] and [map_e] that
maps over all elements of [xs] and threads an accumulator with initial
value [a] through calls to [f]. The list is traversed from left to right
and the first encountered error is returned. *)valfold_left_map_e:('a->'b->('a*'c,'trace)result)->'a->'blist->('a*'clist,'trace)result(** [fold_left_map_s f a xs] is a combination of [fold_left_s] and [map_s] that
maps over all elements of [xs] and threads an accumulator with initial
value [a] through calls to [f]. *)valfold_left_map_s:('a->'b->('a*'c)Lwt.t)->'a->'blist->('a*'clist)Lwt.t(** [fold_left_map_es f a xs] is a combination of [fold_left_es] and [map_es] that
maps over all elements of [xs] and threads an accumulator with initial
value [a] through calls to [f]. The list is traversed from left to right
and the first encountered error is returned. *)valfold_left_map_es:('a->'b->('a*'c,'trace)resultLwt.t)->'a->'blist->('a*'clist,'trace)resultLwt.tvalfold_left_i:(int->'a->'b->'a)->'a->'blist->'avalfold_left_i_e:(int->'a->'b->('a,'trace)result)->'a->'blist->('a,'trace)resultvalfold_left_i_s:(int->'a->'b->'aLwt.t)->'a->'blist->'aLwt.tvalfold_left_i_es:(int->'a->'b->('a,'trace)resultLwt.t)->'a->'blist->('a,'trace)resultLwt.t(** This function is not tail-recursive *)valfold_right:('a->'b->'b)->'alist->'b->'b(** This function is not tail-recursive *)valfold_right_e:('a->'b->('b,'trace)result)->'alist->'b->('b,'trace)result(** This function is not tail-recursive *)valfold_right_s:('a->'b->'bLwt.t)->'alist->'b->'bLwt.t(** This function is not tail-recursive *)valfold_right_es:('a->'b->('b,'trace)resultLwt.t)->'alist->'b->('b,'trace)resultLwt.t(** {3 Double-traversal variants}
As mentioned above, there are no [_p] and [_ep] double-traversors. Use
{!combine} (and variants) to circumvent this. *)valiter2_e:when_different_lengths:'trace->('a->'b->(unit,'trace)result)->'alist->'blist->(unit,'trace)resultvaliter2_s:when_different_lengths:'trace->('a->'b->unitLwt.t)->'alist->'blist->(unit,'trace)resultLwt.tvaliter2_es:when_different_lengths:'trace->('a->'b->(unit,'trace)resultLwt.t)->'alist->'blist->(unit,'trace)resultLwt.tvalmap2_e:when_different_lengths:'trace->('a->'b->('c,'trace)result)->'alist->'blist->('clist,'trace)resultvalmap2_s:when_different_lengths:'trace->('a->'b->'cLwt.t)->'alist->'blist->('clist,'trace)resultLwt.tvalmap2_es:when_different_lengths:'trace->('a->'b->('c,'trace)resultLwt.t)->'alist->'blist->('clist,'trace)resultLwt.tvalrev_map2_e:when_different_lengths:'trace->('a->'b->('c,'trace)result)->'alist->'blist->('clist,'trace)resultvalrev_map2_s:when_different_lengths:'trace->('a->'b->'cLwt.t)->'alist->'blist->('clist,'trace)resultLwt.tvalrev_map2_es:when_different_lengths:'trace->('a->'b->('c,'trace)resultLwt.t)->'alist->'blist->('clist,'trace)resultLwt.tvalfold_left2_e:when_different_lengths:'trace->('a->'b->'c->('a,'trace)result)->'a->'blist->'clist->('a,'trace)resultvalfold_left2_s:when_different_lengths:'trace->('a->'b->'c->'aLwt.t)->'a->'blist->'clist->('a,'trace)resultLwt.tvalfold_left2_es:when_different_lengths:'trace->('a->'b->'c->('a,'trace)resultLwt.t)->'a->'blist->'clist->('a,'trace)resultLwt.t(** This function is not tail-recursive *)valfold_right2_e:when_different_lengths:'trace->('a->'b->'c->('c,'trace)result)->'alist->'blist->'c->('c,'trace)result(** This function is not tail-recursive *)valfold_right2_s:when_different_lengths:'trace->('a->'b->'c->'cLwt.t)->'alist->'blist->'c->('c,'trace)resultLwt.t(** This function is not tail-recursive *)valfold_right2_es:when_different_lengths:'trace->('a->'b->'c->('c,'trace)resultLwt.t)->'alist->'blist->'c->('c,'trace)resultLwt.t(** {3 Scanning variants} *)valfor_all:('a->bool)->'alist->boolvalfor_all_e:('a->(bool,'trace)result)->'alist->(bool,'trace)resultvalfor_all_s:('a->boolLwt.t)->'alist->boolLwt.tvalfor_all_es:('a->(bool,'trace)resultLwt.t)->'alist->(bool,'trace)resultLwt.tvalfor_all_p:('a->boolLwt.t)->'alist->boolLwt.tvalexists:('a->bool)->'alist->boolvalexists_e:('a->(bool,'trace)result)->'alist->(bool,'trace)resultvalexists_s:('a->boolLwt.t)->'alist->boolLwt.tvalexists_es:('a->(bool,'trace)resultLwt.t)->'alist->(bool,'trace)resultLwt.tvalexists_p:('a->boolLwt.t)->'alist->boolLwt.t(** {3 Double-scanning variants}
As mentioned above, there are no [_p] and [_ep] double-scanners. Use
{!combine} (and variants) to circumvent this. *)valfor_all2_e:when_different_lengths:'trace->('a->'b->(bool,'trace)result)->'alist->'blist->(bool,'trace)resultvalfor_all2_s:when_different_lengths:'trace->('a->'b->boolLwt.t)->'alist->'blist->(bool,'trace)resultLwt.tvalfor_all2_es:when_different_lengths:'trace->('a->'b->(bool,'trace)resultLwt.t)->'alist->'blist->(bool,'trace)resultLwt.tvalexists2_e:when_different_lengths:'trace->('a->'b->(bool,'trace)result)->'alist->'blist->(bool,'trace)resultvalexists2_s:when_different_lengths:'trace->('a->'b->boolLwt.t)->'alist->'blist->(bool,'trace)resultLwt.tvalexists2_es:when_different_lengths:'trace->('a->'b->(bool,'trace)resultLwt.t)->'alist->'blist->(bool,'trace)resultLwt.t(** {3 Combine variants}
These are primarily intended to be used for preprocessing before applying
a traversor to the resulting list of pairs. They give alternatives to the
[when_different_lengths] mechanism of the immediate double-traversors
above.
In case the semantic of, say, [map2_es] was unsatisfying, one can use
[map_es] on a [combine]-preprocessed pair of lists. The different variants
of [combine] give different approaches to different-length handling. *)(** [combine_drop ll lr] is a list [l] of pairs of elements taken from the
common-length prefix of [ll] and [lr]. The suffix of whichever list is
longer (if any) is dropped.
More formally [nth l n] is:
- [None] if [n >= min (length ll) (length lr)]
- [Some (Option.get @@ nth ll n, Option.get @@ nth lr n)] otherwise
*)valcombine_drop:'alist->'blist->('a*'b)list(** [combine_with_leftovers ll lr] is a tuple [(combined, leftover)]
where [combined] is [combine_drop ll lr]
and [leftover] is either [Either.Left lsuffix] or [Either.Right rsuffix]
depending on which of [ll] or [lr] is longer. [leftover] is [None] if the
two lists have the same length. *)valcombine_with_leftovers:'alist->'blist->('a*'b)list*('alist,'blist)Either.toption(** {3 Product} *)(** [product xs ys] is the cartesian product of [xs] and [ys].
In other words [product xs ys] is a list containing all the pairs [(x, y)]
where [x] is an element of [xs] and [y] is an element of [ys].
The order of the elements in the returned list is unspecified. *)valproduct:'alist->'blist->('a*'b)list(** {3 Comparison and equality}
The comparison and equality functions are those of the OCaml [Stdlib]. *)valcompare:('a->'a->int)->'alist->'alist->intvalcompare_lengths:'alist->'blist->intvalcompare_length_with:'alist->int->intvalequal:('a->'a->bool)->'alist->'alist->bool(** {3 Sorting}
The sorting functions are those of the OCaml [Stdlib]. *)valsort:('a->'a->int)->'alist->'alistvalstable_sort:('a->'a->int)->'alist->'alistvalfast_sort:('a->'a->int)->'alist->'alistvalsort_uniq:('a->'a->int)->'alist->'alist(** {3 Conversion}
The conversion functions are those of the OCaml [Stdlib]. *)valto_seq:'alist->'aSeq.tvalof_seq:'aSeq.t->'alistvalinit_ep:when_negative_length:'error->int->(int->('a,'errorError_monad.trace)resultLwt.t)->('alist,'errorError_monad.trace)resultLwt.tvalfilter_ep:('a->(bool,'errorError_monad.trace)resultLwt.t)->'alist->('alist,'errorError_monad.trace)resultLwt.tvalpartition_ep:('a->(bool,'errorError_monad.trace)resultLwt.t)->'alist->('alist*'alist,'errorError_monad.trace)resultLwt.tvalpartition_map_ep:('a->(('b,'c)Either.t,'errorError_monad.trace)resultLwt.t)->'alist->('blist*'clist,'errorError_monad.trace)resultLwt.tvaliter_ep:('a->(unit,'errorError_monad.trace)resultLwt.t)->'alist->(unit,'errorError_monad.trace)resultLwt.tvaliteri_ep:(int->'a->(unit,'errorError_monad.trace)resultLwt.t)->'alist->(unit,'errorError_monad.trace)resultLwt.tvalmap_ep:('a->('b,'errorError_monad.trace)resultLwt.t)->'alist->('blist,'errorError_monad.trace)resultLwt.tvalmapi_ep:(int->'a->('b,'errorError_monad.trace)resultLwt.t)->'alist->('blist,'errorError_monad.trace)resultLwt.tvalrev_map_ep:('a->('b,'errorError_monad.trace)resultLwt.t)->'alist->('blist,'errorError_monad.trace)resultLwt.tvalrev_mapi_ep:(int->'a->('b,'errorError_monad.trace)resultLwt.t)->'alist->('blist,'errorError_monad.trace)resultLwt.tvalfilter_map_ep:('a->('boption,'errorError_monad.trace)resultLwt.t)->'alist->('blist,'errorError_monad.trace)resultLwt.tvalconcat_map_ep:('a->('blist,'errortrace)resultLwt.t)->'alist->('blist,'errortrace)resultLwt.tvalfor_all_ep:('a->(bool,'errorError_monad.trace)resultLwt.t)->'alist->(bool,'errorError_monad.trace)resultLwt.tvalexists_ep:('a->(bool,'errorError_monad.trace)resultLwt.t)->'alist->(bool,'errorError_monad.trace)resultLwt.tend# 56 "v8.in.ml"moduleArray:sig# 1 "v8/array.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** This module is a very restricted subset of OCaml's Stdlib Array module.
There is just enough exposed that you can pass arrays around to some
functions and such, but not enough that you can easily shoot yourself in the
foot. (See details below.)
If you need Arrays with more features, you should check the [FallbackArray]
module. *)(** The type of native OCaml arrays. You can construct them with the literal
syntax ([[|"like"; "so"|]]) or obtain them by deserialising data. *)type'at='aarrayvalconcat:'atlist->'atvallength:'at->intvalto_list:'at->'alist(**/**)(* This Array module is the thinnest shim we can get away with for use with Plonk.
To avoid any issues with arrays — notably to avoid exceptions when getting
out of bounds and to avoid any issues with mutability — we shadow [get] and
[set] as well as a few other functions.
Note that we do not shadow every other function. E.g., [of_list]. This is
because those functions might be added later. We only shadow functions which
may cause serious issues. *)valget:[`You_cannot_access_array_content_in_the_protocol]valunsafe_get:[`You_cannot_access_array_content_in_the_protocol]valset:[`You_cannot_modify_array_content_in_the_protocol]valunsafe_set:[`You_cannot_modify_array_content_in_the_protocol](* The [to_list] conversion above is supported, but [to_seq] can be an issue
because different indexes could be read at different times and the array
could have been modified in the mean time (not by the protocol but by an
underlying function. *)valto_seq:[`You_cannot_traverse_arrays_lazily_in_the_protocol]valto_seqi:[`You_cannot_traverse_arrays_lazily_in_the_protocol](* Make can create sharing which is error prone *)valmake:[`You_cannot_build_arrays_with_implicit_sharing_in_the_protocol]valcreate:[`You_cannot_build_arrays_with_implicit_sharing_in_the_protocol]valmake_matrix:[`You_cannot_build_arrays_with_implicit_sharing_in_the_protocol]valcreate_float:[`You_cannot_use_floats_in_the_protocol]valmake_float:[`You_cannot_use_floats_in_the_protocol](* These functions use indexes which can raise exceptions *)valsub:[`You_cannot_cut_arrays_in_the_protocol]valfill:[`You_cannot_fill_arrays_in_the_protocol]valblit:[`You_cannot_blit_arrays_in_the_protocol](* *2 functions can raise exceptions *)valiter2:[`You_cannot_traverse_2_arrays_at_once_in_the_protocol]valmap2:[`You_cannot_traverse_2_arrays_at_once_in_the_protocol]valcombine:[`You_cannot_traverse_2_arrays_at_once_in_the_protocol](* side-effects *)valsort:[`You_cannot_sort_arrays_in_the_protocol]valstable_sort:[`You_cannot_sort_arrays_in_the_protocol]valfast_sort:[`You_cannot_sort_arrays_in_the_protocol]moduleFloatarray:sigendend# 58 "v8.in.ml"moduleSet:sig# 1 "v8/set.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2020 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(* From Lwtreslib *)moduletypeS=sigtypeelttypetvalempty:tvalis_empty:t->boolvalmem:elt->t->boolvaladd:elt->t->tvalsingleton:elt->tvalremove:elt->t->tvalunion:t->t->tvalinter:t->t->tvaldisjoint:t->t->boolvaldiff:t->t->tvalcompare:t->t->intvalequal:t->t->boolvalsubset:t->t->boolvaliter:(elt->unit)->t->unitvaliter_e:(elt->(unit,'trace)result)->t->(unit,'trace)resultvaliter_s:(elt->unitLwt.t)->t->unitLwt.tvaliter_p:(elt->unitLwt.t)->t->unitLwt.tvaliter_es:(elt->(unit,'trace)resultLwt.t)->t->(unit,'trace)resultLwt.tvalmap:(elt->elt)->t->tvalfold:(elt->'a->'a)->t->'a->'avalfold_e:(elt->'a->('a,'trace)result)->t->'a->('a,'trace)resultvalfold_s:(elt->'a->'aLwt.t)->t->'a->'aLwt.tvalfold_es:(elt->'a->('a,'trace)resultLwt.t)->t->'a->('a,'trace)resultLwt.tvalfor_all:(elt->bool)->t->boolvalexists:(elt->bool)->t->boolvalfilter:(elt->bool)->t->tvalfilter_map:(elt->eltoption)->t->tvalpartition:(elt->bool)->t->t*tvalcardinal:t->intvalelements:t->eltlistvalmin_elt:t->eltoptionvalmin_elt_opt:t->eltoptionvalmax_elt:t->eltoptionvalmax_elt_opt:t->eltoptionvalchoose:t->eltoptionvalchoose_opt:t->eltoptionvalsplit:elt->t->t*bool*tvalfind:elt->t->eltoptionvalfind_opt:elt->t->eltoptionvalfind_first:(elt->bool)->t->eltoptionvalfind_first_opt:(elt->bool)->t->eltoptionvalfind_last:(elt->bool)->t->eltoptionvalfind_last_opt:(elt->bool)->t->eltoptionvalof_list:eltlist->tvalto_seq_from:elt->t->eltSeq.tvalto_seq:t->eltSeq.tvalto_rev_seq:t->eltSeq.tvaladd_seq:eltSeq.t->t->tvalof_seq:eltSeq.t->tvaliter_ep:(elt->(unit,'errorError_monad.trace)resultLwt.t)->t->(unit,'errorError_monad.trace)resultLwt.tendmoduleMake(Ord:Compare.COMPARABLE):Swithtypeelt=Ord.tend# 60 "v8.in.ml"moduleMap:sig# 1 "v8/map.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2020 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(* From Lwtreslib *)moduletypeS=sigtypekeytype+!'atvalempty:'atvalis_empty:'at->boolvalmem:key->'at->boolvaladd:key->'a->'at->'atvalupdate:key->('aoption->'aoption)->'at->'atvalsingleton:key->'a->'atvalremove:key->'at->'atvalmerge:(key->'aoption->'boption->'coption)->'at->'bt->'ctvalunion:(key->'a->'a->'aoption)->'at->'at->'atvalcompare:('a->'a->int)->'at->'at->intvalequal:('a->'a->bool)->'at->'at->boolvaliter:(key->'a->unit)->'at->unit(** [iter_e f m] applies [f] to the bindings of [m] one by one in an
unspecified order. If all the applications result in [Ok ()], then the
result of the iteration is [Ok ()]. If any of the applications results in
[Error e] then the iteration stops and the result of the iteration is
[Error e]. *)valiter_e:(key->'a->(unit,'trace)result)->'at->(unit,'trace)resultvaliter_s:(key->'a->unitLwt.t)->'at->unitLwt.tvaliter_p:(key->'a->unitLwt.t)->'at->unitLwt.t(** [iter_es f m] applies [f] to the bindings of [m] in an unspecified order,
one after the other as the promises resolve. If all the applications
result in [Ok ()], then the result of the iteration is [Ok ()]. If any of
the applications results in [Error e] then the iteration stops and the
result of the iteration is [Error e]. *)valiter_es:(key->'a->(unit,'trace)resultLwt.t)->'at->(unit,'trace)resultLwt.tvalfold:(key->'a->'b->'b)->'at->'b->'b(** [fold_e f m init] is
[f k1 d1 init >>? fun acc -> f k2 d2 acc >>? fun acc -> …] where [kN] is
the key bound to [dN] in [m]. *)valfold_e:(key->'a->'b->('b,'trace)result)->'at->'b->('b,'trace)resultvalfold_s:(key->'a->'b->'bLwt.t)->'at->'b->'bLwt.t(** [fold_es f m init] is
[f k1 d1 init >>=? fun acc -> f k2 d2 acc >>=? fun acc -> …] where [kN] is
the key bound to [dN] in [m]. *)valfold_es:(key->'a->'b->('b,'trace)resultLwt.t)->'at->'b->('b,'trace)resultLwt.tvalfor_all:(key->'a->bool)->'at->boolvalexists:(key->'a->bool)->'at->boolvalfilter:(key->'a->bool)->'at->'atvalfilter_map:(key->'a->'boption)->'at->'btvalpartition:(key->'a->bool)->'at->'at*'atvalcardinal:'at->intvalbindings:'at->(key*'a)listvalmin_binding:'at->(key*'a)optionvalmin_binding_opt:'at->(key*'a)optionvalmax_binding:'at->(key*'a)optionvalmax_binding_opt:'at->(key*'a)optionvalchoose:'at->(key*'a)optionvalchoose_opt:'at->(key*'a)optionvalsplit:key->'at->'at*'aoption*'atvalfind:key->'at->'aoptionvalfind_opt:key->'at->'aoptionvalfind_first:(key->bool)->'at->(key*'a)optionvalfind_first_opt:(key->bool)->'at->(key*'a)optionvalfind_last:(key->bool)->'at->(key*'a)optionvalfind_last_opt:(key->bool)->'at->(key*'a)optionvalmap:('a->'b)->'at->'btvalmapi:(key->'a->'b)->'at->'btvalto_seq:'at->(key*'a)Seq.tvalto_rev_seq:'at->(key*'a)Seq.tvalto_seq_from:key->'at->(key*'a)Seq.tvaladd_seq:(key*'a)Seq.t->'at->'atvalof_seq:(key*'a)Seq.t->'atvaliter_ep:(key->'a->(unit,'errorError_monad.trace)resultLwt.t)->'at->(unit,'errorError_monad.trace)resultLwt.tendmoduleMake(Ord:Compare.COMPARABLE):Swithtypekey=Ord.tend# 62 "v8.in.ml"moduleOption:sig# 1 "v8/option.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2020 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Signature from Lwtreslib's option module *)type'at='aoption=None|Someof'avalnone:'aoptionvalnone_e:('aoption,'trace)resultvalnone_s:'aoptionLwt.tvalnone_es:('aoption,'trace)resultLwt.tvalsome:'a->'aoptionvalsome_unit:unitoptionvalsome_nil:'alistoptionvalsome_e:'a->('aoption,'trace)resultvalsome_s:'a->'aoptionLwt.tvalsome_es:'a->('aoption,'trace)resultLwt.tvalvalue:'aoption->default:'a->'avalvalue_e:'aoption->error:'trace->('a,'trace)resultvalvalue_f:'aoption->default:(unit->'a)->'avalvalue_fe:'aoption->error:(unit->'trace)->('a,'trace)resultvalbind:'aoption->('a->'boption)->'boptionvaljoin:'aoptionoption->'aoptionvaleither:'aoption->'aoption->'aoptionvalmap:('a->'b)->'aoption->'boptionvalmap_s:('a->'bLwt.t)->'aoption->'boptionLwt.tvalmap_e:('a->('b,'trace)result)->'aoption->('boption,'trace)resultvalmap_es:('a->('b,'trace)resultLwt.t)->'aoption->('boption,'trace)resultLwt.tvalfold:none:'a->some:('b->'a)->'boption->'avalfold_s:none:'a->some:('b->'aLwt.t)->'boption->'aLwt.tvalfold_f:none:(unit->'a)->some:('b->'a)->'boption->'avaliter:('a->unit)->'aoption->unitvaliter_s:('a->unitLwt.t)->'aoption->unitLwt.tvaliter_e:('a->(unit,'trace)result)->'aoption->(unit,'trace)resultvaliter_es:('a->(unit,'trace)resultLwt.t)->'aoption->(unit,'trace)resultLwt.tvalis_none:'aoption->boolvalis_some:'aoption->boolvalequal:('a->'a->bool)->'aoption->'aoption->boolvalcompare:('a->'a->int)->'aoption->'aoption->intvalto_result:none:'trace->'aoption->('a,'trace)resultvalof_result:('a,'e)result->'aoptionvalto_list:'aoption->'alistvalto_seq:'aoption->'aSeq.t(** [catch f] is [Some (f ())] if [f] does not raise an exception, it is
[None] otherwise.
You should only use [catch] when you truly do not care about
what exception may be raised during the evaluation of [f ()]. If you need
to inspect the raised exception, or if you need to pass it along, consider
{!Result.catch} instead.
If [catch_only] is set, then only exceptions [e] such that [catch_only e]
is [true] are caught.
Whether [catch_only] is set or not, you cannot catch non-deterministic
runtime exceptions of OCaml such as {!Stack_overflow} and
{!Out_of_memory} nor system exceptions such as {!Unix.Unix_error}. *)valcatch:?catch_only:(exn->bool)->(unit->'a)->'aoption(** [catch_s f] is a promise that resolves to [Some x] if and when [f ()]
resolves to [x]. Alternatively, it resolves to [None] if and when [f ()]
is rejected.
You should only use [catch_s] when you truly do not care about
what exception may be raised during the evaluation of [f ()]. If you need
to inspect the raised exception, or if you need to pass it along, consider
{!Result.catch_s} instead.
If [catch_only] is set, then only exceptions [e] such that [catch_only e]
is [true] are caught.
Whether [catch_only] is set or not, you cannot catch non-deterministic
runtime exceptions of OCaml such as {!Stack_overflow} and
{!Out_of_memory} nor system exceptions such as {!Unix.Unix_error}. *)valcatch_s:?catch_only:(exn->bool)->(unit->'aLwt.t)->'aoptionLwt.tend# 64 "v8.in.ml"moduleResult:sig# 1 "v8/result.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2020 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)type('a,'e)t=('a,'e)result=Okof'a|Errorof'e(***)valok:'a->('a,'e)resultvalok_s:'a->('a,'e)resultLwt.tvalerror:'e->('a,'e)resultvalerror_s:'e->('a,'e)resultLwt.tvalreturn:'a->('a,'e)resultvalreturn_unit:(unit,'e)resultvalreturn_none:('aoption,'e)resultvalreturn_some:'a->('aoption,'e)resultvalreturn_nil:('alist,'e)resultvalreturn_true:(bool,'e)resultvalreturn_false:(bool,'e)resultvalvalue:('a,'e)result->default:'a->'avalvalue_f:('a,'e)result->default:(unit->'a)->'avalbind:('a,'e)result->('a->('b,'e)result)->('b,'e)resultvalbind_s:('a,'e)result->('a->('b,'e)resultLwt.t)->('b,'e)resultLwt.tvalbind_error:('a,'e)result->('e->('a,'f)result)->('a,'f)resultvalbind_error_s:('a,'e)result->('e->('a,'f)resultLwt.t)->('a,'f)resultLwt.tvaljoin:(('a,'e)result,'e)result->('a,'e)resultvalmap:('a->'b)->('a,'e)result->('b,'e)result(* NOTE: [map_e] is [bind] *)valmap_e:('a->('b,'e)result)->('a,'e)result->('b,'e)resultvalmap_s:('a->'bLwt.t)->('a,'e)result->('b,'e)resultLwt.t(* NOTE: [map_es] is [bind_s] *)valmap_es:('a->('b,'e)resultLwt.t)->('a,'e)result->('b,'e)resultLwt.tvalmap_error:('e->'f)->('a,'e)result->('a,'f)result(* NOTE: [map_error_e] is [bind_error] *)valmap_error_e:('e->('a,'f)result)->('a,'e)result->('a,'f)resultvalmap_error_s:('e->'fLwt.t)->('a,'e)result->('a,'f)resultLwt.t(* NOTE: [map_error_es] is [bind_error_s] *)valmap_error_es:('e->('a,'f)resultLwt.t)->('a,'e)result->('a,'f)resultLwt.tvalfold:ok:('a->'c)->error:('e->'c)->('a,'e)result->'cvaliter:('a->unit)->('a,'e)result->unitvaliter_s:('a->unitLwt.t)->('a,'e)result->unitLwt.tvaliter_error:('e->unit)->('a,'e)result->unitvaliter_error_s:('e->unitLwt.t)->('a,'e)result->unitLwt.tvalis_ok:('a,'e)result->boolvalis_error:('a,'e)result->boolvalequal:ok:('a->'a->bool)->error:('e->'e->bool)->('a,'e)result->('a,'e)result->boolvalcompare:ok:('a->'a->int)->error:('e->'e->int)->('a,'e)result->('a,'e)result->intvalto_option:('a,'e)result->'aoptionvalof_option:error:'e->'aoption->('a,'e)resultvalto_list:('a,'e)result->'alistvalto_seq:('a,'e)result->'aSeq.t(** [catch f] is [try Ok (f ()) with e -> Error e]: it is [Ok x] if [f ()]
evaluates to [x], and it is [Error e] if [f ()] raises [e].
See {!WithExceptions.S.Result.to_exn} for a converse function.
If [catch_only] is set, then only exceptions [e] such that [catch_only e]
is [true] are caught.
Whether [catch_only] is set or not, you cannot catch non-deterministic
runtime exceptions of OCaml such as {!Stack_overflow} and
{!Out_of_memory} nor system exceptions such as {!Unix.Unix_error}. *)valcatch:?catch_only:(exn->bool)->(unit->'a)->('a,exn)result(** [catch_f f handler] is equivalent to [map_error (catch f) handler].
In other words, it catches exceptions in [f ()] and either returns the
value in an [Ok] or passes the exception to [handler] for the [Error].
[catch_only] has the same use as with [catch]. The same restriction on
catching non-deterministic runtime exceptions applies. *)valcatch_f:?catch_only:(exn->bool)->(unit->'a)->(exn->'error)->('a,'error)result(** [catch_s] is [catch] but for Lwt promises. Specifically, [catch_s f]
returns a promise that resolves to [Ok x] if and when [f ()] resolves to
[x], or to [Error exc] if and when [f ()] is rejected with [exc].
If [catch_only] is set, then only exceptions [e] such that [catch_only e]
is [true] are caught.
Whether [catch_only] is set or not, you cannot catch non-deterministic
runtime exceptions of OCaml such as {!Stack_overflow} and
{!Out_of_memory} nor system exceptions such as {!Unix.Unix_error}. *)valcatch_s:?catch_only:(exn->bool)->(unit->'aLwt.t)->('a,exn)resultLwt.tend# 66 "v8.in.ml"moduleRPC_arg:sig# 1 "v8/RPC_arg.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** See [src/lib_rpc/RPC_arg.mli] for documentation *)type'attype'aarg='atvalmake:?descr:string->name:string->destruct:(string->('a,string)result)->construct:('a->string)->unit->'aargtypedescr={name:string;descr:stringoption}valdescr:'aarg->descrvalbool:boolargvalint:intargvaluint:intargvalint32:int32argvaluint31:int32argvalint64:int64argvaluint63:int64argvalstring:stringargvallike:'aarg->?descr:string->string->'aargtype('a,'b)eq=Eq:('a,'a)eqvaleq:'aarg->'barg->('a,'b)eqoptionend# 68 "v8.in.ml"moduleRPC_path:sig# 1 "v8/RPC_path.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)type('prefix,'params)ttype('prefix,'params)path=('prefix,'params)ttype'prefixcontext=('prefix,'prefix)pathvalroot:unitcontextvalopen_root:'acontextvaladd_suffix:('prefix,'params)path->string->('prefix,'params)pathval(/):('prefix,'params)path->string->('prefix,'params)pathvaladd_arg:('prefix,'params)path->'aRPC_arg.t->('prefix,'params*'a)pathval(/:):('prefix,'params)path->'aRPC_arg.t->('prefix,'params*'a)pathvaladd_final_args:('prefix,'params)path->'aRPC_arg.t->('prefix,'params*'alist)pathval(/:*):('prefix,'params)path->'aRPC_arg.t->('prefix,'params*'alist)pathend# 70 "v8.in.ml"moduleRPC_query:sig# 1 "v8/RPC_query.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)type'attype'aquery='atvalempty:unitquerytype('a,'b)fieldvalfield:?descr:string->string->'aRPC_arg.t->'a->('b->'a)->('b,'a)fieldvalopt_field:?descr:string->string->'aRPC_arg.t->('b->'aoption)->('b,'aoption)fieldvalflag:?descr:string->string->('b->bool)->('b,bool)fieldvalmulti_field:?descr:string->string->'aRPC_arg.t->('b->'alist)->('b,'alist)fieldtype('a,'b,'c)open_queryvalquery:'b->('a,'b,'b)open_queryval(|+):('a,'b,'c->'d)open_query->('a,'c)field->('a,'b,'d)open_queryvalseal:('a,'b,'a)open_query->'attypeuntyped=(string*string)listexceptionInvalidofstringvalparse:'aquery->untyped->'aend# 72 "v8.in.ml"moduleRPC_service:sig# 1 "v8/RPC_service.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** HTTP methods. *)typemeth=[`GET|`POST|`DELETE|`PUT|`PATCH]type(+'meth,'prefix,'params,'query,'input,'output)tconstraint'meth=[<meth]type(+'meth,'prefix,'params,'query,'input,'output)service=('meth,'prefix,'params,'query,'input,'output)tvalget_service:?description:string->query:'queryRPC_query.t->output:'outputData_encoding.t->('prefix,'params)RPC_path.t->([`GET],'prefix,'params,'query,unit,'output)servicevalpost_service:?description:string->query:'queryRPC_query.t->input:'inputData_encoding.t->output:'outputData_encoding.t->('prefix,'params)RPC_path.t->([`POST],'prefix,'params,'query,'input,'output)servicevaldelete_service:?description:string->query:'queryRPC_query.t->output:'outputData_encoding.t->('prefix,'params)RPC_path.t->([`DELETE],'prefix,'params,'query,unit,'output)servicevalpatch_service:?description:string->query:'queryRPC_query.t->input:'inputData_encoding.t->output:'outputData_encoding.t->('prefix,'params)RPC_path.t->([`PATCH],'prefix,'params,'query,'input,'output)servicevalput_service:?description:string->query:'queryRPC_query.t->input:'inputData_encoding.t->output:'outputData_encoding.t->('prefix,'params)RPC_path.t->([`PUT],'prefix,'params,'query,'input,'output)serviceend# 74 "v8.in.ml"moduleRPC_answer:sig# 1 "v8/RPC_answer.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Return type for service handler *)type'ot=[`Okof'o(* 200 *)|`OkChunkof'o(* 200 but send answer as chunked transfer encoding *)|`OkStreamof'ostream(* 200 *)|`Createdofstringoption(* 201 *)|`No_content(* 204 *)|`Unauthorizedoferrorlistoption(* 401 *)|`Forbiddenoferrorlistoption(* 403 *)|`Not_foundoferrorlistoption(* 404 *)|`Conflictoferrorlistoption(* 409 *)|`Erroroferrorlistoption(* 500 *)]and'astream={next:unit->'aoptionLwt.t;shutdown:unit->unit}valreturn:'o->'otLwt.t(** [return_chunked] is identical to [return] but it indicates to the server
that the result might be long and that the serialisation should be done in
mutliple chunks.
You should use [return_chunked] when returning an (unbounded or potentially
large) list, array, map, or other such set. *)valreturn_chunked:'o->'otLwt.tvalreturn_stream:'ostream->'otLwt.tvalnot_found:'otLwt.tvalfail:errorlist->'atLwt.tend# 76 "v8.in.ml"moduleRPC_directory:sig# 1 "v8/RPC_directory.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Dispatch tree *)type'prefixttype'prefixdirectory='prefixt(** Empty list of dispatch trees *)valempty:'prefixdirectoryvalmap:('a->'bLwt.t)->'bdirectory->'adirectoryvalprefix:('pr,'p)RPC_path.path->'pdirectory->'prdirectoryvalmerge:?strategy:[`Raise|`Pick_left|`Pick_right]->'adirectory->'adirectory->'adirectory(** Possible error while registering services. *)typestep=|Staticofstring|DynamicofRPC_arg.descr|DynamicTailofRPC_arg.descrtypeconflict=|CServiceofRPC_service.meth|CDir|CBuilder|CDynDescrofstring*string|CTail|CTypesofRPC_arg.descr*RPC_arg.descr|CTypeofRPC_arg.descr*stringlistexceptionConflictofsteplist*conflict(** Registering handler in service tree.
The [chunked] parameter controls whether the answer to the RPC is chunk
encoded (i.e., the serialisation is split and the caller receives the answer
in multiple chunks) or not. Defaults to [false]. Set to [true] for RPCs that
return potentially large collections (e.g., unbounded lists). *)valregister:chunked:bool->'prefixdirectory->('meth,'prefix,'params,'query,'input,'output)RPC_service.t->('params->'query->'input->'outputtzresultLwt.t)->'prefixdirectoryvalopt_register:chunked:bool->'prefixdirectory->('meth,'prefix,'params,'query,'input,'output)RPC_service.t->('params->'query->'input->'outputoptiontzresultLwt.t)->'prefixdirectoryvalgen_register:'prefixdirectory->('meth,'prefix,'params,'query,'input,'output)RPC_service.t->('params->'query->'input->[<'outputRPC_answer.t]Lwt.t)->'prefixdirectoryvallwt_register:chunked:bool->'prefixdirectory->('meth,'prefix,'params,'query,'input,'output)RPC_service.t->('params->'query->'input->'outputLwt.t)->'prefixdirectory(** Registering handler in service tree. Curryfied variant. *)valregister0:chunked:bool->unitdirectory->('m,unit,unit,'q,'i,'o)RPC_service.t->('q->'i->'otzresultLwt.t)->unitdirectoryvalregister1:chunked:bool->'prefixdirectory->('m,'prefix,unit*'a,'q,'i,'o)RPC_service.t->('a->'q->'i->'otzresultLwt.t)->'prefixdirectoryvalregister2:chunked:bool->'prefixdirectory->('m,'prefix,(unit*'a)*'b,'q,'i,'o)RPC_service.t->('a->'b->'q->'i->'otzresultLwt.t)->'prefixdirectoryvalregister3:chunked:bool->'prefixdirectory->('m,'prefix,((unit*'a)*'b)*'c,'q,'i,'o)RPC_service.t->('a->'b->'c->'q->'i->'otzresultLwt.t)->'prefixdirectoryvalregister4:chunked:bool->'prefixdirectory->('m,'prefix,(((unit*'a)*'b)*'c)*'d,'q,'i,'o)RPC_service.t->('a->'b->'c->'d->'q->'i->'otzresultLwt.t)->'prefixdirectoryvalregister5:chunked:bool->'prefixdirectory->('m,'prefix,((((unit*'a)*'b)*'c)*'d)*'e,'q,'i,'o)RPC_service.t->('a->'b->'c->'d->'e->'q->'i->'otzresultLwt.t)->'prefixdirectoryvalopt_register0:chunked:bool->unitdirectory->('m,unit,unit,'q,'i,'o)RPC_service.t->('q->'i->'ooptiontzresultLwt.t)->unitdirectoryvalopt_register1:chunked:bool->'prefixdirectory->('m,'prefix,unit*'a,'q,'i,'o)RPC_service.t->('a->'q->'i->'ooptiontzresultLwt.t)->'prefixdirectoryvalopt_register2:chunked:bool->'prefixdirectory->('m,'prefix,(unit*'a)*'b,'q,'i,'o)RPC_service.t->('a->'b->'q->'i->'ooptiontzresultLwt.t)->'prefixdirectoryvalopt_register3:chunked:bool->'prefixdirectory->('m,'prefix,((unit*'a)*'b)*'c,'q,'i,'o)RPC_service.t->('a->'b->'c->'q->'i->'ooptiontzresultLwt.t)->'prefixdirectoryvalopt_register4:chunked:bool->'prefixdirectory->('m,'prefix,(((unit*'a)*'b)*'c)*'d,'q,'i,'o)RPC_service.t->('a->'b->'c->'d->'q->'i->'ooptiontzresultLwt.t)->'prefixdirectoryvalopt_register5:chunked:bool->'prefixdirectory->('m,'prefix,((((unit*'a)*'b)*'c)*'d)*'e,'q,'i,'o)RPC_service.t->('a->'b->'c->'d->'e->'q->'i->'ooptiontzresultLwt.t)->'prefixdirectoryvalgen_register0:unitdirectory->('m,unit,unit,'q,'i,'o)RPC_service.t->('q->'i->[<'oRPC_answer.t]Lwt.t)->unitdirectoryvalgen_register1:'prefixdirectory->('m,'prefix,unit*'a,'q,'i,'o)RPC_service.t->('a->'q->'i->[<'oRPC_answer.t]Lwt.t)->'prefixdirectoryvalgen_register2:'prefixdirectory->('m,'prefix,(unit*'a)*'b,'q,'i,'o)RPC_service.t->('a->'b->'q->'i->[<'oRPC_answer.t]Lwt.t)->'prefixdirectoryvalgen_register3:'prefixdirectory->('m,'prefix,((unit*'a)*'b)*'c,'q,'i,'o)RPC_service.t->('a->'b->'c->'q->'i->[<'oRPC_answer.t]Lwt.t)->'prefixdirectoryvalgen_register4:'prefixdirectory->('m,'prefix,(((unit*'a)*'b)*'c)*'d,'q,'i,'o)RPC_service.t->('a->'b->'c->'d->'q->'i->[<'oRPC_answer.t]Lwt.t)->'prefixdirectoryvalgen_register5:'prefixdirectory->('m,'prefix,((((unit*'a)*'b)*'c)*'d)*'e,'q,'i,'o)RPC_service.t->('a->'b->'c->'d->'e->'q->'i->[<'oRPC_answer.t]Lwt.t)->'prefixdirectoryvallwt_register0:chunked:bool->unitdirectory->('m,unit,unit,'q,'i,'o)RPC_service.t->('q->'i->'oLwt.t)->unitdirectoryvallwt_register1:chunked:bool->'prefixdirectory->('m,'prefix,unit*'a,'q,'i,'o)RPC_service.t->('a->'q->'i->'oLwt.t)->'prefixdirectoryvallwt_register2:chunked:bool->'prefixdirectory->('m,'prefix,(unit*'a)*'b,'q,'i,'o)RPC_service.t->('a->'b->'q->'i->'oLwt.t)->'prefixdirectoryvallwt_register3:chunked:bool->'prefixdirectory->('m,'prefix,((unit*'a)*'b)*'c,'q,'i,'o)RPC_service.t->('a->'b->'c->'q->'i->'oLwt.t)->'prefixdirectoryvallwt_register4:chunked:bool->'prefixdirectory->('m,'prefix,(((unit*'a)*'b)*'c)*'d,'q,'i,'o)RPC_service.t->('a->'b->'c->'d->'q->'i->'oLwt.t)->'prefixdirectoryvallwt_register5:chunked:bool->'prefixdirectory->('m,'prefix,((((unit*'a)*'b)*'c)*'d)*'e,'q,'i,'o)RPC_service.t->('a->'b->'c->'d->'e->'q->'i->'oLwt.t)->'prefixdirectory(** Registering dynamic subtree. *)valregister_dynamic_directory:?descr:string->'prefixdirectory->('prefix,'a)RPC_path.t->('a->'adirectoryLwt.t)->'prefixdirectoryend# 78 "v8.in.ml"moduleBase58:sig# 1 "v8/base58.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)type'aencoding(** Decoder for a given kind of data. It returns [None] when
the decoded data does not start with the expected prefix. *)valsimple_decode:'aencoding->string->'aoption(** Encoder for a given kind of data. *)valsimple_encode:'aencoding->'a->string(** An extensible sum-type for decoded data: one case per known
"prefix". See for instance [Hash.Block_hash.Hash] or
[Environment.Ed25519.Public_key_hash]. *)typedata=..(** Register a new encoding. The function might raise [Invalid_arg] if
the provided [prefix] overlaps with a previously registered
prefix. The [to_raw] and [of_raw] are the ad-hoc
serialisation/deserialisation for the data. The [wrap] should wrap
the deserialised value into the extensible sum-type [data] (see
the generic function [decode]). *)valregister_encoding:prefix:string->length:int->to_raw:('a->string)->of_raw:(string->'aoption)->wrap:('a->data)->'aencoding(** Checks that an encoding has a certain prefix and length. *)valcheck_encoded_prefix:'aencoding->string->int->unit(** Generic decoder. It returns [None] when the decoded data does
not start with a registered prefix. *)valdecode:string->dataoptionend# 80 "v8.in.ml"moduleS:sig# 1 "v8/s.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2020 Metastate AG <hello@metastate.dev> *)(* Copyright (c) 2022 Nomadic Labs. <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Generic interface for a datatype with comparison, pretty-printer
and serialization functions. *)moduletypeT=sigtypetincludeCompare.Swithtypet:=tvalpp:Format.formatter->t->unitvalencoding:tData_encoding.tvalto_bytes:t->bytesvalof_bytes:bytes->toptionend(** Generic interface for a datatype with comparison, pretty-printer,
serialization functions and a hashing function. *)moduletypeHASHABLE=sigincludeTtypehashvalhash:t->hashvalhash_raw:bytes->hashend(** {2 Hash Types} *)(** The signature of an abstract hash type, as produced by functor
{!Make_SHA256}. The {!t} type is abstracted for separating the
various kinds of hashes in the system at typing time. Each type is
equipped with functions to use it as is of as keys in the database
or in memory sets and maps. *)moduletypeMINIMAL_HASH=sigtypetvalname:stringvaltitle:stringvalpp:Format.formatter->t->unitvalpp_short:Format.formatter->t->unitincludeCompare.Swithtypet:=tvalhash_bytes:?key:bytes->byteslist->tvalhash_string:?key:string->stringlist->tvalzero:tendmoduletypeRAW_DATA=sigtypetvalsize:int(* in bytes *)valto_bytes:t->bytesvalof_bytes_opt:bytes->toptionvalof_bytes_exn:bytes->tendmoduletypeB58_DATA=sigtypetvalto_b58check:t->stringvalto_short_b58check:t->stringvalof_b58check_exn:string->tvalof_b58check_opt:string->toptiontypeBase58.data+=Dataoftvalb58check_encoding:tBase58.encodingendmoduletypeENCODER=sigtypetvalencoding:tData_encoding.tvalrpc_arg:tRPC_arg.tendmoduletypeINDEXES_SET=sigincludeSet.Svalrandom_elt:t->eltvalencoding:tData_encoding.tendmoduletypeINDEXES_MAP=sigincludeMap.Svalencoding:'aData_encoding.t->'atData_encoding.tendmoduletypeINDEXES=sigtypetmoduleSet:INDEXES_SETwithtypeelt=tmoduleMap:INDEXES_MAPwithtypekey=tendmoduletypeHASH=sigincludeMINIMAL_HASHincludeRAW_DATAwithtypet:=tincludeB58_DATAwithtypet:=tincludeENCODERwithtypet:=tincludeINDEXESwithtypet:=tendmoduletypeMERKLE_TREE=sigtypeeltincludeHASHvalcompute:eltlist->tvalempty:ttypepath=Leftofpath*t|Rightoft*path|Opvalcompute_path:eltlist->int->pathvalcheck_path:path->elt->t*intvalpath_encoding:pathData_encoding.tendmoduletypeSIGNATURE_PUBLIC_KEY_HASH=sigtypetvalpp:Format.formatter->t->unitvalpp_short:Format.formatter->t->unitincludeCompare.Swithtypet:=tincludeRAW_DATAwithtypet:=tincludeB58_DATAwithtypet:=tincludeENCODERwithtypet:=tincludeINDEXESwithtypet:=tvalzero:tendmoduletypeSIGNATURE_PUBLIC_KEY=sigtypetvalpp:Format.formatter->t->unitincludeCompare.Swithtypet:=tincludeB58_DATAwithtypet:=tincludeENCODERwithtypet:=ttypepublic_key_hash_tvalhash:t->public_key_hash_tvalsize:t->int(* in bytes *)valof_bytes_without_validation:bytes->toptionendmoduletypeSIGNATURE=sigmodulePublic_key_hash:SIGNATURE_PUBLIC_KEY_HASHmodulePublic_key:SIGNATURE_PUBLIC_KEYwithtypepublic_key_hash_t:=Public_key_hash.ttypetvalpp:Format.formatter->t->unitincludeRAW_DATAwithtypet:=tincludeCompare.Swithtypet:=tincludeB58_DATAwithtypet:=tincludeENCODERwithtypet:=tvalzero:ttypewatermark(** Check a signature *)valcheck:?watermark:watermark->Public_key.t->t->bytes->boolendmoduletypeAGGREGATE_SIGNATURE=sigincludeSIGNATUREvalaggregate_check:(Public_key.t*watermarkoption*bytes)list->t->boolvalaggregate_signature_opt:tlist->toptionendmoduletypeSPLIT_SIGNATURE=sigincludeSIGNATUREtypeprefixtypesplitted={prefix:prefixoption;suffix:Bytes.t}valsplit_signature:t->splittedvalof_splitted:splitted->toptionvalprefix_encoding:prefixData_encoding.tendmoduletypeFIELD=sigtypet(** The order of the finite field *)valorder:Z.t(** Minimal number of bytes required to encode a value of the field. *)valsize_in_bytes:int(** [check_bytes bs] returns [true] if [bs] is a correct byte
representation of a field element *)valcheck_bytes:Bytes.t->bool(** The neutral element for the addition *)valzero:t(** The neutral element for the multiplication *)valone:t(** [add a b] returns [a + b mod order] *)valadd:t->t->t(** [mul a b] returns [a * b mod order] *)valmul:t->t->t(** [eq a b] returns [true] if [a = b mod order], else [false] *)valeq:t->t->bool(** [negate x] returns [-x mod order]. Equivalently, [negate x] returns the
unique [y] such that [x + y mod order = 0]
*)valnegate:t->t(** [inverse_opt x] returns [x^-1] if [x] is not [0] as an option, else [None] *)valinverse_opt:t->toption(** [pow x n] returns [x^n] *)valpow:t->Z.t->t(** From a predefined bytes representation, construct a value t. It is not
required that to_bytes [(Option.get (of_bytes_opt t)) = t]. By default,
little endian encoding is used and the given element is modulo the prime
order *)valof_bytes_opt:Bytes.t->toption(** Convert the value t to a bytes representation which can be used for
hashing for instance. It is not required that [to_bytes (Option.get
(of_bytes_opt t)) = t]. By default, little endian encoding is used, and
length of the resulting bytes may vary depending on the order.
*)valto_bytes:t->Bytes.tend(** Module type for the prime fields GF(p) *)moduletypePRIME_FIELD=sigincludeFIELD(** Actual number of bytes allocated for a value of type t *)valsize_in_memory:int(** [of_z x] builds an element t from the Zarith element [x]. [mod order] is
applied if [x >= order] or [x < 0]. *)valof_z:Z.t->t(** [to_z x] builds a Zarith element, using the decimal representation.
Arithmetic on the result can be done using the modular functions on
integers *)valto_z:t->Z.tendmoduletypeCURVE=sig(** The type of the element in the elliptic curve *)typet(** Actual number of bytes allocated for a value of type t *)valsize_in_memory:int(** The size of a point representation, in bytes *)valsize_in_bytes:intmoduleScalar:FIELD(** Check if a point, represented as a byte array, is on the curve **)valcheck_bytes:Bytes.t->bool(** Attempt to construct a point from a byte array *)valof_bytes_opt:Bytes.t->toption(** Return a representation in bytes *)valto_bytes:t->Bytes.t(** Zero of the elliptic curve *)valzero:t(** A fixed generator of the elliptic curve *)valone:t(** Return the addition of two element *)valadd:t->t->t(** Double the element *)valdouble:t->t(** Return the opposite of the element *)valnegate:t->t(** Return [true] if the two elements are algebraically the same *)valeq:t->t->bool(** Multiply an element by a scalar *)valmul:t->Scalar.t->tendend# 82 "v8.in.ml"moduleBlake2B:sig# 1 "v8/blake2B.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Builds a new Hash type using Blake2B. *)(** The parameters for creating a new Hash type using
{!Make_Blake2B}. Both {!name} and {!title} are only informative,
used in error messages and serializers. *)moduletypeName=sigvalname:stringvaltitle:stringvalsize:intoptionendmoduletypePrefixedName=sigincludeNamevalb58check_prefix:stringend(** Builds a new Hash type using Blake2B. *)moduleMake_minimal(Name:Name):S.MINIMAL_HASHmoduletypeRegister=sigvalregister_encoding:prefix:string->length:int->to_raw:('a->string)->of_raw:(string->'aoption)->wrap:('a->Base58.data)->'aBase58.encodingendmoduleMake(Register:Register)(Name:PrefixedName):S.HASHend# 84 "v8.in.ml"moduleBls:sig# 1 "v8/bls.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2022 Nomadic Labs. <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Tezos - BLS12-381 cryptography *)includeS.AGGREGATE_SIGNATUREwithtypewatermark:=bytes(** Module to access/expose the primitives of BLS12-381 *)modulePrimitive:sigmoduleFr:S.PRIME_FIELDmoduleG1:S.CURVEwithtypeScalar.t=Fr.tmoduleG2:S.CURVEwithtypeScalar.t=Fr.tvalpairing_check:(G1.t*G2.t)list->boolendend# 86 "v8.in.ml"moduleEd25519:sig# 1 "v8/ed25519.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Tezos - Ed25519 cryptography *)includeS.SIGNATUREwithtypewatermark:=bytesend# 88 "v8.in.ml"moduleSecp256k1:sig# 1 "v8/secp256k1.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Tezos - Secp256k1 cryptography *)includeS.SIGNATUREwithtypewatermark:=bytesend# 90 "v8.in.ml"moduleP256:sig# 1 "v8/p256.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Tezos - P256 cryptography *)includeS.SIGNATUREwithtypewatermark:=bytesend# 92 "v8.in.ml"moduleChain_id:sig# 1 "v8/chain_id.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)includeS.HASHend# 94 "v8.in.ml"moduleSignature:sig# 1 "v8/signature.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2022 Nomadic Labs. <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)typepublic_key_hash=|Ed25519ofEd25519.Public_key_hash.t|Secp256k1ofSecp256k1.Public_key_hash.t|P256ofP256.Public_key_hash.t|BlsofBls.Public_key_hash.ttypepublic_key=|Ed25519ofEd25519.Public_key.t|Secp256k1ofSecp256k1.Public_key.t|P256ofP256.Public_key.t|BlsofBls.Public_key.ttypewatermark=|Block_headerofChain_id.t|EndorsementofChain_id.t|Generic_operation|Customofbytestypesignature=|Ed25519ofEd25519.t|Secp256k1ofSecp256k1.t|P256ofP256.t|BlsofBls.t|UnknownofBytes.ttypeprefix=Bls_prefixofBytes.tincludeS.SPLIT_SIGNATUREwithtypePublic_key_hash.t=public_key_hashandtypePublic_key.t=public_keyandtypewatermark:=watermarkandtypeprefix:=prefixandtypet=signaturevalsize:t->intend# 96 "v8.in.ml"moduleBlock_hash:sig# 1 "v8/block_hash.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Blocks hashes / IDs. *)includeS.HASHend# 98 "v8.in.ml"moduleOperation_hash:sig# 1 "v8/operation_hash.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Operations hashes / IDs. *)includeS.HASHend# 100 "v8.in.ml"moduleOperation_list_hash:sig# 1 "v8/operation_list_hash.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Blocks hashes / IDs. *)includeS.MERKLE_TREEwithtypeelt=Operation_hash.tend# 102 "v8.in.ml"moduleOperation_list_list_hash:sig# 1 "v8/operation_list_list_hash.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Blocks hashes / IDs. *)includeS.MERKLE_TREEwithtypeelt=Operation_list_hash.tend# 104 "v8.in.ml"moduleProtocol_hash:sig# 1 "v8/protocol_hash.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Protocol hashes / IDs. *)includeS.HASHend# 106 "v8.in.ml"moduleContext_hash:sig# 1 "v8/context_hash.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Committed context hashes / IDs. *)includeS.HASH(** The module for representing the hash version of a context *)moduleVersion:sig(** The type for hash versions. *)typet=privateintincludeCompare.Swithtypet:=t(** [pp] is the pretty-printer for hash versions. *)valpp:Format.formatter->t->unit(** [encoding] is the data encoding for hash versions. *)valencoding:tData_encoding.t(** [of_int i] is the hash version equivalent to [i].
This function raises [Invalid_argument] if [i] is not an unsigned 16-bit integer. *)valof_int:int->tendtypeversion=Version.tend# 108 "v8.in.ml"moduleSapling:sig# 1 "v8/sapling.mli"(* The MIT License (MIT)
*
* Copyright (c) 2019-2020 Nomadic Labs <contact@nomadic-labs.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. *)moduleCiphertext:sigtypetvalencoding:tData_encoding.tvalget_memo_size:t->intendmoduleCommitment:sigtypetvalencoding:tData_encoding.tvalvalid_position:int64->boolendmoduleCV:sigtypetvalencoding:tData_encoding.tendmoduleHash:sigtypetvalcompare:t->t->intvalencoding:tData_encoding.tvalto_bytes:t->Bytes.tvalof_bytes_exn:Bytes.t->tvaluncommitted:height:int->tvalmerkle_hash:height:int->t->t->tvalof_commitment:Commitment.t->tvalto_commitment:t->Commitment.tendmoduleNullifier:sigtypetvalencoding:tData_encoding.tvalcompare:t->t->intendmoduleUTXO:sigtyperktypespend_prooftypespend_sigtypeoutput_prooftypeinput={cv:CV.t;nf:Nullifier.t;rk:rk;proof_i:spend_proof;signature:spend_sig;}valinput_encoding:inputData_encoding.ttypeoutput={cm:Commitment.t;proof_o:output_proof;ciphertext:Ciphertext.t;}valoutput_encoding:outputData_encoding.ttypebinding_sigtypetransaction={inputs:inputlist;outputs:outputlist;binding_sig:binding_sig;balance:Int64.t;root:Hash.t;bound_data:string;}valtransaction_encoding:transactionData_encoding.tvalbinding_sig_encoding:binding_sigData_encoding.tmoduleLegacy:sigtypetransaction_new=transactiontypetransaction={inputs:inputlist;outputs:outputlist;binding_sig:binding_sig;balance:Int64.t;root:Hash.t;}valtransaction_encoding:transactionData_encoding.tvalcast:transaction->transaction_newendendmoduleVerification:sigtypetvalwith_verification_ctx:(t->'a)->'avalcheck_spend:t->UTXO.input->Hash.t->string->boolvalcheck_output:t->UTXO.output->boolvalfinal_check:t->UTXO.transaction->string->boolendend# 110 "v8.in.ml"moduleTimelock:sig# 1 "v8/timelock.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2020 Nomadic Labs, <contact@nomadic-labs.com *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Contains a value (the decryption of the ciphertext) that can be provably
recovered in [time] sequential operation or with the rsa secret. *)typechestvalchest_encoding:chestData_encoding.t(** Provably opens a chest in a short time. *)typechest_keyvalchest_key_encoding:chest_keyData_encoding.t(** Result of the opening of a chest.
The opening can fail in two way which we distinguish to blame the right person.
One can provide a false unlocked_value or unlocked_proof, in which case
we return [Bogus_opening] and the provider of the chest key is at fault.
Otherwise, one can lock the wrong key or put garbage in the ciphertext in which case
we return [Bogus_cipher] and the provider of the chest is at fault.
Otherwise we return [Correct payload] where payload was what had
originally been put in the chest. *)typeopening_result=CorrectofBytes.t|Bogus_cipher|Bogus_opening(** Takes a chest, chest key and time and tries to recover the underlying
plaintext. See the documentation of opening_result. *)valopen_chest:chest->chest_key->time:int->opening_result(** Gives the size of the underlying plaintext in a chest in bytes.
Used for gas accounting*)valget_plaintext_size:chest->intend# 112 "v8.in.ml"moduleVdf:sig# 1 "v8/vdf.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2022 Nomadic Labs, <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Size of a group element, also called form, in bytes *)valform_size_bytes:int(** Size of the class group discriminant in bytes *)valdiscriminant_size_bytes:int(** Class group discriminant, prime number uniquely defining a class group *)typediscriminant(** VDF challenge *)typechallenge(** VDF result *)typeresult(** VDF proof *)typeproof(** VDF difficulty, that is log of the number of group element compositions
done in the prover *)typedifficulty=Int64.tvaldiscriminant_to_bytes:discriminant->bytesvaldiscriminant_of_bytes_opt:bytes->discriminantoptionvalchallenge_to_bytes:challenge->bytesvalchallenge_of_bytes_opt:bytes->challengeoptionvalresult_to_bytes:result->bytesvalresult_of_bytes_opt:bytes->resultoptionvalproof_to_bytes:proof->bytesvalproof_of_bytes_opt:bytes->proofoption(** [generate_discriminant ?seed size], function generating a
discriminant/group *)valgenerate_discriminant:?seed:Bytes.t->int->discriminant(** [generate_challenge discriminant seed], function generating a class group
element used as a VDF challenge *)valgenerate_challenge:discriminant->Bytes.t->challenge(** [prove_vdf discriminant challenge difficulty], function taking a class
group/discriminant, a vdf challenge and a difficulty and returning a vdf
result and proof *)valprove:discriminant->challenge->difficulty->result*proof(** [verify_vdf discriminant challenge difficulty result proof] function taking
a class group/discriminant, a vdf challenge, difficulty, result and proof and
returning true if the proof verifies else false
@raise Invalid_argument when inputs are invalid *)valverify:discriminant->challenge->difficulty->result->proof->boolend# 114 "v8.in.ml"moduleMicheline:sig# 1 "v8/micheline.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)typeannot=stringlisttype('l,'p)node=|Intof'l*Z.t|Stringof'l*string|Bytesof'l*bytes|Primof'l*'p*('l,'p)nodelist*annot|Seqof'l*('l,'p)nodelisttype'pcanonicaltypecanonical_locationvaldummy_location:canonical_locationvalroot:'pcanonical->(canonical_location,'p)nodevalcanonical_location_encoding:canonical_locationData_encoding.encodingvalcanonical_encoding:variant:string->'lData_encoding.encoding->'lcanonicalData_encoding.encodingvallocation:('l,'p)node->'lvalannotations:('l,'p)node->stringlistvalstrip_locations:(_,'p)node->'pcanonicalend# 116 "v8.in.ml"moduleBlock_header:sig# 1 "v8/block_header.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)typeshell_header={level:Int32.t;(** Height of the block, from the genesis block. *)proto_level:int;(** Number (uint8) of protocol changes since genesis modulo 256. *)predecessor:Block_hash.t;(** Hash of the preceding block. *)timestamp:Time.t;(** Timestamp at which the block is claimed to have been created. *)validation_passes:int;(** Number (uint8) of validation passes (also number of lists of operations). *)operations_hash:Operation_list_list_hash.t;(** Hash of the list of lists (actually root hashes of merkle trees)
of operations included in the block. There is one list of
operations per validation pass. *)fitness:Bytes.tlist;(** A sequence of sequences of unsigned bytes, ordered by length and
then lexicographically. It represents the claimed fitness of the
chain ending in this block. *)context:Context_hash.t;(** Hash of the state of the context after application of this block. *)}valshell_header_encoding:shell_headerData_encoding.ttypet={shell:shell_header;protocol_data:bytes}includeS.HASHABLEwithtypet:=tandtypehash:=Block_hash.tend# 118 "v8.in.ml"moduleBounded:sig# 1 "v8/bounded.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2022 Trili Tech, <contact@trili.tech> *)(* Copyright (c) 2022 Nomadic Labs, <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** This module implements bounded (or refined) versions of data types. *)(** Bounds.
Formally each [B : BOUND] represents the interval of all values
between [B.min_value] and [B.max_value]. This is a closed interval,
i.e. the endpoints are included.
Intervals can be empty, for example [struct let min_value = 1; let
max_value 0 end] is empty. *)moduletypeBOUNDS=sig(** [ocaml_type] is the type used for the internal representation of
values within the bounded interval. This is the type that values
in the interval are converted to and from. E.g., for an interval
of 32-bit integers [ocaml_type = int32]. *)typeocaml_type(** [min_value] represents the minimal value (included) reprensatable. *)valmin_value:ocaml_type(** [max_value] represents the maximal value (included)
reprensatable. *)valmax_value:ocaml_typeend(** Signature for an interval of (included values) with an encoding
and projection functions towards the underlying ocaml datatype. *)moduletypeS=sig(** Internal representation of a bounded value. *)typet(** Underlying OCaml representation for the bounded value. *)typeocaml_typeincludeBOUNDSwithtypeocaml_type:=ocaml_typeincludeCompare.Swithtypet:=t(** A (partial) encoding of the datatype. If the encoded value is
out of bounds, an exception may be raised. See
{!val:Data_encoding.conv_with_guard}. *)valencoding:tData_encoding.t(** A pretty-printer for values of type [t]. *)valpp:Format.formatter->t->unit(** [to_value t] is a projection to the OCaml representation of the
bounded value [t]. *)valto_value:t->ocaml_type(** [of_value ocaml_value] represents [ocaml_value] as a bounded
value. Returns [None] if the value is outside of the bounds
specified by {!val:min_value} and {!val:max_value}. *)valof_value:ocaml_type->toptionend(** Allows to build interval of int64 integers. The encoding used is
{!val:Data_encoding.int64} regardless of the actual bounds. *)moduleInt64(B:BOUNDSwithtypeocaml_type:=int64):Swithtypeocaml_type:=int64(** Allows to build interval of int32 integers. The encoding used is
{!val:Data_encoding.int32} regardless of the actual bounds. *)moduleInt32(B:BOUNDSwithtypeocaml_type:=int32):Swithtypeocaml_type:=int32(** Allows to build interval of non negative int32 integers. The
encoding used is {!val:Data_encoding.int32} regardless of the
actual bounds. *)moduleNon_negative_int32:Swithtypeocaml_type:=int32(** Allows to build interval of built-in OCaml int integers. The
encoding used is {!val:Data_encoding.int31} regardless of the
actual bounds.
@raise Invalid_argument if the bounds provided cannot be
representable on 4 bytes (depends on whether [int] is represented
on 4 bytes or 8 bytes which depends on the machine architecture)..
*)moduleInt31(B:BOUNDSwithtypeocaml_type:=int):Swithtypeocaml_type:=int(** Allows to build interval of int integers representable on 2
bytes. The encoding used is {!val:Data_encoding.int16} regardless
of the actual bounds.
@raise Invalid_argument if the bounds provided cannot be
representable on 2 bytes. *)moduleInt16(B:BOUNDSwithtypeocaml_type:=int):Swithtypeocaml_type:=int(** Allows to build interval of non-negative int integers
representable on 2 bytes. The encoding used is
{!val:Data_encoding.uint16} regardless of the actual bounds.
@raise Invalid_argument if the bounds provided cannot be
representable on 2 bytes. *)moduleUint16(B:BOUNDSwithtypeocaml_type:=int):Swithtypeocaml_type:=int(** Allows to build interval of non-negative int integers
representable on 1 bytes. The encoding used is
{!val:Data_encoding.int8} regardless of the actual bounds.
@raise Invalid_argument if the bounds provided cannot be
representable on 1 bytes. *)moduleInt8(B:BOUNDSwithtypeocaml_type:=int):Swithtypeocaml_type:=int(** Allows to build interval of non-negative int integers
representable on 1 bytes. The encoding used is
{!val:Data_encoding.uint8} regardless of the actual bounds.
@raise Invalid_argument if the bounds provided cannot be
representable on 1 bytes. *)moduleUint8(B:BOUNDSwithtypeocaml_type:=int):Swithtypeocaml_type:=intend# 120 "v8.in.ml"moduleFitness:sig# 1 "v8/fitness.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** The fitness of a block is defined as a list of bytes,
compared in a lexicographical order (longer list are greater). *)includeS.Twithtypet=byteslistend# 122 "v8.in.ml"moduleOperation:sig# 1 "v8/operation.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Tezos operations. *)typeshell_header={branch:Block_hash.t;(** The operation is only valid in a branch containing the
block [branch]. *)}valshell_header_encoding:shell_headerData_encoding.ttypet={shell:shell_header;proto:bytes}includeS.HASHABLEwithtypet:=tandtypehash:=Operation_hash.tend# 124 "v8.in.ml"moduleContext:sig# 1 "v8/context.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** View over the context store, restricted to types, access and
functional manipulation of an existing context. *)(* Copy/paste of Environment_context_sigs.Context.S *)(** The tree depth of a fold. See the [fold] function for more information. *)typedepth=[`Eqofint|`Leofint|`Ltofint|`Geofint|`Gtofint](** The type for context configuration. *)typeconfig(** The equality function for context configurations. If two context have the
same configuration, they will generate the same context hashes. *)valequal_config:config->config->boolmoduletypeVIEW=sig(** The type for context views. *)typet(** The type for context keys. *)typekey(** The type for context values. *)typevalue(** The type for context trees. *)typetree(** {2 Getters} *)(** [mem t k] is an Lwt promise that resolves to [true] iff [k] is bound
to a value in [t]. *)valmem:t->key->boolLwt.t(** [mem_tree t k] is like {!mem} but for trees. *)valmem_tree:t->key->boolLwt.t(** [find t k] is an Lwt promise that resolves to [Some v] if [k] is
bound to the value [v] in [t] and [None] otherwise. *)valfind:t->key->valueoptionLwt.t(** [find_tree t k] is like {!find} but for trees. *)valfind_tree:t->key->treeoptionLwt.t(** [list t key] is the list of files and sub-nodes stored under [k] in [t].
The result order is not specified but is stable.
[offset] and [length] are used for pagination. *)vallist:t->?offset:int->?length:int->key->(string*tree)listLwt.t(** [length t key] is an Lwt promise that resolves to the number of
files and sub-nodes stored under [k] in [t].
It is equivalent to [list t k >|= List.length] but has a
constant-time complexity. *)vallength:t->key->intLwt.t(** {2 Setters} *)(** [add t k v] is an Lwt promise that resolves to [c] such that:
- [k] is bound to [v] in [c];
- and [c] is similar to [t] otherwise.
If [k] was already bound in [t] to a value that is physically equal
to [v], the result of the function is a promise that resolves to
[t]. Otherwise, the previous binding of [k] in [t] disappears. *)valadd:t->key->value->tLwt.t(** [add_tree] is like {!add} but for trees. *)valadd_tree:t->key->tree->tLwt.t(** [remove t k v] is an Lwt promise that resolves to [c] such that:
- [k] is unbound in [c];
- and [c] is similar to [t] otherwise. *)valremove:t->key->tLwt.t(** {2 Folding} *)(** [fold ?depth t root ~order ~init ~f] recursively folds over the trees
and values of [t]. The [f] callbacks are called with a key relative
to [root]. [f] is never called with an empty key for values; i.e.,
folding over a value is a no-op.
The depth is 0-indexed. If [depth] is set (by default it is not), then [f]
is only called when the conditions described by the parameter is true:
- [Eq d] folds over nodes and values of depth exactly [d].
- [Lt d] folds over nodes and values of depth strictly less than [d].
- [Le d] folds over nodes and values of depth less than or equal to [d].
- [Gt d] folds over nodes and values of depth strictly more than [d].
- [Ge d] folds over nodes and values of depth more than or equal to [d].
If [order] is [`Sorted] (the default), the elements are traversed in
lexicographic order of their keys. For large nodes, it is memory-consuming,
use [`Undefined] for a more memory efficient [fold]. *)valfold:?depth:depth->t->key->order:[`Sorted|`Undefined]->init:'a->f:(key->tree->'a->'aLwt.t)->'aLwt.t(** {2 Configuration} *)(** [config t] is [t]'s hash configuration. *)valconfig:t->configendmoduleKind:sigtypet=[`Value|`Tree]endmoduletypeTREE=sig(** [Tree] provides immutable, in-memory partial mirror of the
context, with lazy reads and delayed writes. The trees are Merkle
trees that carry the same hash as the part of the context they
mirror.
Trees are immutable and non-persistent (they disappear if the
host crash), held in memory for efficiency, where reads are done
lazily and writes are done only when needed, e.g. on
[Context.commit]. If a key is modified twice, only the last
value will be written to disk on commit. *)(** The type for context views. *)typet(** The type for context trees. *)typetreeincludeVIEWwithtypet:=treeandtypetree:=tree(** [empty _] is the empty tree. *)valempty:t->tree(** [is_empty t] is true iff [t] is [empty _]. *)valis_empty:tree->bool(** [kind t] is [t]'s kind. It's either a tree node or a leaf
value. *)valkind:tree->Kind.t(** [to_value t] is an Lwt promise that resolves to [Some v] if [t]
is a leaf tree and [None] otherwise. It is equivalent to [find t
[]]. *)valto_value:tree->valueoptionLwt.t(** [of_value _ v] is an Lwt promise that resolves to the leaf tree
[v]. Is is equivalent to [add (empty _) [] v]. *)valof_value:t->value->treeLwt.t(** [hash t] is [t]'s Merkle hash. *)valhash:tree->Context_hash.t(** [equal x y] is true iff [x] and [y] have the same Merkle hash. *)valequal:tree->tree->bool(** {2 Caches} *)(** [clear ?depth t] clears all caches in the tree [t] for subtrees with a
depth higher than [depth]. If [depth] is not set, all of the subtrees are
cleared. *)valclear:?depth:int->tree->unitendmoduleProof:sig(** Proofs are compact representations of trees which can be shared
between peers.
This is expected to be used as follows:
- A first peer runs a function [f] over a tree [t]. While performing
this computation, it records: the hash of [t] (called [before]
below), the hash of [f t] (called [after] below) and a subset of [t]
which is needed to replay [f] without any access to the first peer's
storage. Once done, all these informations are packed into a proof of
type [t] that is sent to the second peer.
- The second peer generates an initial tree [t'] from [p] and computes
[f t']. Once done, it compares [t']'s hash and [f t']'s hash to [before]
and [after]. If they match, they know that the result state [f t'] is a
valid context state, without having to have access to the full storage
of the first peer. *)(** The type for file and directory names. *)typestep=string(** The type for values. *)typevalue=bytes(** The type of indices for inodes' children. *)typeindex=int(** The type for hashes. *)typehash=Context_hash.t(** The type for (internal) inode proofs.
These proofs encode large directories into a tree-like structure. This
reflects irmin-pack's way of representing nodes and computing
hashes (tree-like representations for nodes scales better than flat
representations).
[length] is the total number of entries in the children of the inode.
It's the size of the "flattened" version of that inode. [length] can be
used to prove the correctness of operations such [Tree.length] and
[Tree.list ~offset ~length] in an efficient way.
In proofs with [version.is_binary = false], an inode at depth 0 has a
[length] of at least [257]. Below that threshold a [Node] tag is used in
[tree]. That threshold is [3] when [version.is_binary = true].
[proofs] contains the children proofs. It is a sparse list of ['a] values.
These values are associated to their index in the list, and the list is
kept sorted in increasing order of indices. ['a] can be a concrete proof
or a hash of that proof.
In proofs with [version.is_binary = true], inodes have at most 2 proofs
(indexed 0 or 1).
In proofs with [version.is_binary = false], inodes have at most 32 proofs
(indexed from 0 to 31). *)type'ainode={length:int;proofs:(index*'a)list}(** The type for inode extenders.
An extender is a compact representation of a sequence of [inode] which
contain only one child. As for inodes, The ['a] parameter can be a
concrete proof or a hash of that proof.
If an inode proof contains singleton children [i_0, ..., i_n] such as:
[{length=l; proofs = [ (i_0, {proofs = ... { proofs = [ (i_n, p) ] }})]}],
then it is compressed into the inode extender
[{length=l; segment = [i_0;..;i_n]; proof=p}] sharing the same lenght [l]
and final proof [p]. *)type'ainode_extender={length:int;segment:indexlist;proof:'a}(** The type for compressed and partial Merkle tree proofs.
Tree proofs do not provide any guarantee with the ordering of
computations. For instance, if two effects commute, they won't be
distinguishable by this kind of proofs.
[Value v] proves that a value [v] exists in the store.
[Blinded_value h] proves a value with hash [h] exists in the store.
[Node ls] proves that a a "flat" node containing the list of files [ls]
exists in the store.
In proofs with [version.is_binary = true], the length of [ls] is at most
2.
In proofs with [version.is_binary = false], the length of [ls] is at most
256.
[Blinded_node h] proves that a node with hash [h] exists in the store.
[Inode i] proves that an inode [i] exists in the store.
[Extender e] proves that an inode extender [e] exist in the store. *)typetree=|Valueofvalue|Blinded_valueofhash|Nodeof(step*tree)list|Blinded_nodeofhash|Inodeofinode_treeinode|Extenderofinode_treeinode_extender(** The type for inode trees. It is a subset of [tree], limited to nodes.
[Blinded_inode h] proves that an inode with hash [h] exists in the store.
[Inode_values ls] is similar to trees' [Node].
[Inode_tree i] is similar to tree's [Inode].
[Inode_extender e] is similar to trees' [Extender]. *)andinode_tree=|Blinded_inodeofhash|Inode_valuesof(step*tree)list|Inode_treeofinode_treeinode|Inode_extenderofinode_treeinode_extender(** The type for kinded hashes. *)typekinded_hash=[`Valueofhash|`Nodeofhash]moduleStream:sig(** Stream proofs represent an explicit traversal of a Merle tree proof.
Every element (a node, a value, or a shallow pointer) met is first
"compressed" by shallowing its children and then recorded in the proof.
As stream proofs directly encode the recursive construction of the
Merkle root hash is slightly simpler to implement: verifier simply
need to hash the compressed elements lazily, without any memory or
choice.
Moreover, the minimality of stream proofs is trivial to check.
Once the computation has consumed the compressed elements required,
it is sufficient to check that no more compressed elements remain
in the proof.
However, as the compressed elements contain all the hashes of their
shallow children, the size of stream proofs is larger
(at least double in size in practice) than tree proofs, which only
contains the hash for intermediate shallow pointers. *)(** The type for elements of stream proofs.
[Value v] is a proof that the next element read in the store is the
value [v].
[Node n] is a proof that the next element read in the store is the
node [n].
[Inode i] is a proof that the next element read in the store is the
inode [i].
[Inode_extender e] is a proof that the next element read in the store
is the node extender [e]. *)typeelt=|Valueofvalue|Nodeof(step*kinded_hash)list|Inodeofhashinode|Inode_extenderofhashinode_extender(** The type for stream proofs.
The sequence [e_1 ... e_n] proves that the [e_1], ..., [e_n] are
read in the store in sequence. *)typet=eltSeq.tendtypestream=Stream.t(** The type for proofs of kind ['a].
A proof [p] proves that the state advanced from [before p] to
[after p]. [state p]'s hash is [before p], and [state p] contains
the minimal information for the computation to reach [after p].
[version p] is the proof version, it packs several informations.
[is_stream] discriminates between the stream proofs and the tree proofs.
[is_binary] discriminates between proofs emitted from
[Tezos_context(_memory).Context_binary] and
[Tezos_context(_memory).Context].
It will also help discriminate between the data encoding techniques used.
The version is meant to be decoded and encoded using the
{!Tezos_context_helpers.Context.decode_proof_version} and
{!Tezos_context_helpers.Context.encode_proof_version}. *)type'at={version:int;before:kinded_hash;after:kinded_hash;state:'a;}endincludeVIEWwithtypekey=stringlistandtypevalue=bytesmoduleTree:TREEwithtypet:=tandtypekey:=keyandtypevalue:=valueandtypetree:=tree(** [verify p f] runs [f] in checking mode. [f] is a function that takes a
tree as input and returns a new version of the tree and a result. [p] is a
proof, that is a minimal representation of the tree that contains what [f]
should be expecting.
Therefore, contrary to trees found in a storage, the contents of the trees
passed to [f] may not be available. For this reason, looking up a value at
some [path] can now produce three distinct outcomes:
- A value [v] is present in the proof [p] and returned : [find tree path]
is a promise returning [Some v];
- [path] is known to have no value in [tree] : [find tree path] is a
promise returning [None]; and
- [path] is known to have a value in [tree] but [p] does not provide it
because [f] should not need it: [verify] returns an error classifying
[path] as an invalid path (see below).
The same semantics apply to all operations on the tree [t] passed to [f]
and on all operations on the trees built from [f].
The generated tree is the tree after [f] has completed. That tree is
disconnected from any storage (i.e. [index]). It is possible to run
operations on it as long as they don't require loading shallowed subtrees.
The result is [Error (`Msg _)] if the proof is rejected:
- For tree proofs: when [p.before] is different from the hash of
[p.state];
- For tree and stream proofs: when [p.after] is different from the hash
of [f p.state];
- For tree proofs: when [f p.state] tries to access invalid paths in
[p.state];
- For stream proofs: when the proof is not consumed in the exact same
order it was produced;
- For stream proofs: when the proof is too short or not empty once [f] is
done.
@raise Failure if the proof version is invalid or incompatible with the
verifier. *)type('proof,'result)verifier:='proof->(tree->(tree*'result)Lwt.t)->(tree*'result,[`Proof_mismatchofstring|`Stream_too_longofstring|`Stream_too_shortofstring])resultLwt.t(** The type for tree proofs.
Guarantee that the given computation performs exactly the same state
operations as the generating computation, *in some order*. *)typetree_proof:=Proof.treeProof.t(** [verify_tree_proof] is the verifier of tree proofs. *)valverify_tree_proof:(tree_proof,'a)verifier(** The type for stream proofs.
Guarantee that the given computation performs exactly the same state
operations as the generating computation, in the exact same order. *)typestream_proof:=Proof.streamProof.t(** [verify_stream] is the verifier of stream proofs. *)valverify_stream_proof:(stream_proof,'a)verifiermoduletypePROOF_ENCODING=sigvaltree_proof_encoding:tree_proofData_encoding.tvalstream_proof_encoding:stream_proofData_encoding.tend(** Proof encoding for binary tree Merkle proofs *)moduleProof_encoding:sig(** V1: using vanilla Data_encoding. Easier to parse by non-OCaml programs
but less efficient *)moduleV1:sig(** Encoding for 32-tree proofs *)moduleTree32:PROOF_ENCODING(** Encoding for binary tree proofs *)moduleTree2:PROOF_ENCODINGend(** V2 : using Compact_encoding. Smaller than V1 but more complex parser
is required. *)moduleV2:sig(** Encoding for 32-tree proofs *)moduleTree32:PROOF_ENCODING(** Encoding for binary tree proofs *)moduleTree2:PROOF_ENCODINGendendvalcomplete:t->string->stringlistLwt.t(** Get the hash version used for the context *)valget_hash_version:t->Context_hash.Version.t(** Set the hash version used for the context. It may recalculate the hashes
of the whole context, which can be a long process.
Returns an Error if the hash version is unsupported. *)valset_hash_version:t->Context_hash.Version.t->tError_monad.shell_tzresultLwt.ttypecache_keytypecache_value=..moduletypeCACHE=sig(** Type for context view. A context contains a cache. A cache is
made of subcaches. Each subcache has its own size limit. The
limit of its subcache is called a layout and can be initialized
via the [set_cache_layout] function. *)typet(** Size for subcaches and values of the cache. Units are not
specified and left to the economic protocol. *)typesize(** Index type to index caches. *)typeindex(** Identifier type for keys. *)typeidentifier(** A key uniquely identifies a cached [value] in some subcache. *)typekey(** Cached values inhabit an extensible type. *)typevalue=..(** [key_of_identifier ~cache_index identifier] builds a key from the
[cache_index] and the [identifier].
No check are made to ensure the validity of the index. *)valkey_of_identifier:cache_index:index->identifier->key(** [identifier_of_key key] returns the identifier associated to the
[key]. *)validentifier_of_key:key->identifier(** [pp fmt cache] is a pretty printer for a [cache]. *)valpp:Format.formatter->t->unit(** [find ctxt k = Some v] if [v] is the value associated to [k] in
in the cache where [k] is. Returns [None] if there is no such
value in the cache of [k]. This function is in the Lwt monad
because if the value has not been constructed, it is constructed
on the fly. *)valfind:t->key->valueoptionLwt.t(** [set_cache_layout ctxt layout] sets the caches of [ctxt] to
comply with given [layout]. If there was already a cache in
[ctxt], it is erased by the new layout.
Otherwise, a fresh collection of empty caches is reconstructed
from the new [layout]. Notice that cache [key]s are invalidated
in that case, i.e., [get t k] will return [None]. *)valset_cache_layout:t->sizelist->tLwt.t(** [update ctxt k (Some (e, size))] returns a cache where the value
[e] of [size] is associated to key [k]. If [k] is already in the
cache, the cache entry is updated.
[update ctxt k None] removes [k] from the cache. *)valupdate:t->key->(value*size)option->t(** [sync ctxt ~cache_nonce] updates the context with the domain of
the cache computed so far. Such function is expected to be called
at the end of the validation of a block, when there is no more
accesses to the cache.
[cache_nonce] identifies the block that introduced new cache
entries. The nonce should identify uniquely the block which
modifies this value. It cannot be the block hash for circularity
reasons: The value of the nonce is stored onto the context and
consequently influences the context hash of the very same
block. Such nonce cannot be determined by the shell and its
computation is delegated to the economic protocol.
*)valsync:t->cache_nonce:Bytes.t->tLwt.t(** [clear ctxt] removes all cache entries. *)valclear:t->t(** {3 Cache introspection} *)(** [list_keys ctxt ~cache_index] returns the list of cached keys in
cache numbered [cache_index] along with their respective
[size]. The returned list is sorted in terms of their age in the
cache, the oldest coming first. If [cache_index] is invalid,
then this function returns [None]. *)vallist_keys:t->cache_index:index->(key*size)listoption(** [key_rank index ctxt key] returns the number of cached value older
than the given [key]; or, [None] if the [key] is not a cache key. *)valkey_rank:t->key->intoption(** {3 Cache helpers for RPCs} *)(** [future_cache_expectation ctxt ~time_in_blocks] returns [ctxt] except
that the entries of the caches that are presumably too old to
still be in the caches in [n_blocks] are removed.
This function is based on a heuristic. The context maintains
the median of the number of removed entries: this number is
multiplied by `n_blocks` to determine the entries that are
likely to be removed in `n_blocks`. *)valfuture_cache_expectation:t->time_in_blocks:int->t(** [cache_size ctxt ~cache_index] returns an overapproximation of
the size of the cache. Returns [None] if [cache_index] is not a
valid cache index. *)valcache_size:t->cache_index:index->sizeoption(** [cache_size_limit ctxt ~cache_index] returns the maximal size of
the cache indexed by [cache_index]. Returns [None] if
[cache_index] is not a valid cache index. *)valcache_size_limit:t->cache_index:index->sizeoptionendmoduleCache:CACHEwithtypet:=tandtypesize:=intandtypeindex:=intandtypeidentifier:=stringandtypekey=cache_keyandtypevalue=cache_valueend# 126 "v8.in.ml"moduleUpdater:sig# 1 "v8/updater.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** Tezos Protocol Environment - Protocol updater. *)(** Validation result: the record returned by the protocol
on the successful validation of a block. *)typevalidation_result={context:Context.t;(** The resulting context, it will be used for the next block. *)fitness:Fitness.t;(** The effective fitness of the block (to be compared with the one
'announced' in the block header). *)message:stringoption;(** An optional informative message, akin to a 'git commit' message,
which can be attached to the [context] when it's being commited. *)max_operations_ttl:int;(** The "time-to-live" of operations for the next block: any
operation whose 'branch' is older than 'ttl' blocks in the past
cannot be included in the next block. *)last_allowed_fork_level:Int32.t;(** The level of the last block for which the node might consider an
alternate branch. The shell should consider as invalid any branch
whose fork point is older (has a lower level) than the
given value. *)}typequota={max_size:int;(** The maximum size (in bytes) of the serialized list of
operations. *)max_op:intoption;(** The maximum number of operations in a block.
[None] means no limit. *)}typerpc_context={block_hash:Block_hash.t;block_header:Block_header.shell_header;context:Context.t;}(** This is the signature of a Tezos protocol implementation. It has
access to the standard library and the Environment module. *)moduletypePROTOCOL=sig(** The maximum size of a block header in bytes. *)valmax_block_length:int(** The maximum size of an {!operation} in bytes. This value is bigger than the size
of the bytes required for {!operation_data}, because this value accounts
for the shell header. *)valmax_operation_data_length:int(** Operations quota for each validation pass. The length of the
list denotes the number of validation passes. *)valvalidation_passes:quotalist(** The economic protocol-specific type of blocks. *)typeblock_header_data(** Encoding for economic protocol-specific part of block headers. *)valblock_header_data_encoding:block_header_dataData_encoding.t(** A fully parsed block header. *)typeblock_header={shell:Block_header.shell_header;protocol_data:block_header_data;}(** Economic protocol-specific side information computed by the
protocol during the validation of a block. Should not include
information about the evaluation of operations which is handled
separately by {!operation_metadata}. To be used as an execution
trace by tools (client, indexer). Not necessary for
validation. *)typeblock_header_metadata(** Encoding for economic protocol-specific block metadata. *)valblock_header_metadata_encoding:block_header_metadataData_encoding.t(** The economic protocol-specific type of operations. *)typeoperation_data(** Economic protocol-specific side information computed by the
protocol during the validation of each operation, to be used
conjointly with {!block_header_metadata}. *)typeoperation_receipt(** A fully parsed operation. *)typeoperation={shell:Operation.shell_header;protocol_data:operation_data;}(** Encoding for economoic protocol-specific operation data. *)valoperation_data_encoding:operation_dataData_encoding.t(** Encoding for eonomic protocol-specific operation receipts. *)valoperation_receipt_encoding:operation_receiptData_encoding.t(** Encoding that mixes an operation data and its receipt. *)valoperation_data_and_receipt_encoding:(operation_data*operation_receipt)Data_encoding.t(** [acceptable_pass op] gives the validation pass in which the
input operation [op] can appear. For instance, it results in
[Some 0] if [op] only belongs to the first pass. When [op] is
ill-formed, [acceptable_pass op] returns [None]. *)valacceptable_pass:operation->intoption(** [compare_operations (oph1,op1) (oph2,op2)] defines a total
ordering relation on valid operations.
The following requirements must be satisfied: [oph1] is the
[Operation.hash.p1], [oph2] is [Operation.hash op2] and that
[op1] and [op2] are valid in the same context.
[compare_operations (oph1,op1) (oph2,op2) = 0] happens only if
[Operation_hash.compare oph1 oph2 = 0], meaning [op1 = op2] only
when [op1] and [op2] are structurally identical.
Two operations of different validation_passes are compared in the
reverse order of their [validation_pass]: the one with the
smaller [validation_pass] is compared as being the greater.
When belonging to the same validation_pass, two operations
comparison depends on their static parameters. An abstract weight
is computed for each operation based on its static parameters.
When two operations' weights are compared as equal,
[compare_operation (oph1,op1) (oph2,op2)] is
[Operation_hash.compare oph1 oph2].
[compare_operations] can be used as a [compare] component of an
{!Stdlib.Map.OrderedType}, or any such collection which relies on
a total comparison function. *)valcompare_operations:Operation_hash.t*operation->Operation_hash.t*operation->int(** {2 Block (and operation) validation and application}
The following functions may be used when an existing block is
received through the network, when a new block is created, or
when operations are considered on their own e.g. in a mempool or
during an RPC call.
Validation aims at deciding quickly whether a block or
an operation is valid, with minimal computations and without
writing anything in the storage. A block is valid if it can be
applied without failure. An operation is valid if it can be
safely included in a block without causing it to fail.
The application of an operation updates the {!Context.t} with
regards to its semantics (e.g. updating balances after a
transaction). The application of a block updates the context
with all its operations and some additional global
effects. Isolated operations may be applied as part of an RPC
call to simulate their effects.
Blocks and operations must always be validated before they are
applied. Indeed, the application assumes their validity as a
precondition, meaning that the application of an invalid block
might yield incorrect results instead of failing cleanly.
Note that in protocol versions <= K, where the validation
functions do not yet exist, the validation of existing blocks is
done by trying to apply it using the [Partial_validation] mode
below. Therefore, the application of a validated block may still
fail in these protocols. *)(** The mode indicates the circumstances in which a block and/or
operations are validated or applied, and contains specific
information. It must be provided as an argument to
[begin_validation] and [begin_application]. *)typemode=|Applicationofblock_header(** Standard validation or application of a preexisting block. *)|Partial_validationofblock_header(** Partial validation of a preexisting block. This mode is
meant to quickly reject obviously invalid alternate
branches by only performing a subset of checks.
Therefore, application of blocks or operations makes no
sense in this mode: calling [begin_application] with this
mode returns an error. *)|Constructionof{predecessor_hash:Block_hash.t;timestamp:Time.t;block_header_data:block_header_data;}(** Construction of a new block. The main difference with the
previous modes is that we cannot provide the block header to the
[begin_] functions, since the block does not exist yet. Note that
the [begin_] functions may be called in this mode without knowing
yet which operations will be included in the future block.
The provided [block_header_data] is not expected to be the final
value of the field of the same type in the {!type-block_header} of
the constructed block. Instead, it should be a protocol-specific,
good enough, "prototype" of the final value. E.g. if the
{!block_header_data} type for the current economic protocol includes
a signature, then the provided [block_header_data] should contain a
fake signature (since providing a correct signature is not possible
at this stage). *)|Partial_constructionof{predecessor_hash:Block_hash.t;timestamp:Time.t;}(** Minimal construction of a new virtual block, with the purpose of
being able to validate/apply operations of interest. This mode may
be used by the mempool (though the [Mempool] module below is better
suited for this) or by some RPCs
e.g. [preapply/operations]. Calling the [finalize_] functions makes
no sense in this mode. *)(** A functional state that is transmitted throughout the validation
of a block (or during the lifetime of a mempool or RPC). It is
created by [begin_validation] below, updated by
[validate_operation], and required by [finalize_validation].
This state is immutable thus validator or baker implementations
are allowed to pause, replay or backtrack throughout validation
steps. *)typevalidation_state(** Similar to {!validation_state}, but for the application process. *)typeapplication_state(** [begin_validation predecessor_context chain_id mode
~predecessor] initializes the {!validation_state} for the
validation process of an existing or new block.
[predecessor_context] and [predecessor] are the resulting
context and shell header of the predecessor block. Exceptionally
in {!Partial_validation} mode, they may instead come from any
ancestor block that is more recent (i.e. has a greater level)
than the current head's "last_allowed_fork_level".
[mode] specifies the circumstances of validation and also
carries additional information: see {!mode}.
Note that for protocol versions <= K where [begin_validation]
does not exist yet, this calls the old [begin_application] by
necessity. However, in [Application] mode, this calls the old
[begin_application] in [Partial_validation] mode in order to run
more quickly. This preserves the behavior of [precheck] in
[lib_validation/block_validation.ml] for old protocols. It does
mean that the application of a validated block may fail in these
protocols. *)valbegin_validation:Context.t->Chain_id.t->mode->predecessor:Block_header.shell_header->validation_statetzresultLwt.t(** Validate an operation. If successful, return the updated
{!validation_state}.
[check_signature] indicates whether the signature should be
checked. It defaults to [true] because the signature needs to be
correct for the operation to be valid. This argument exists for
special cases where it is acceptable to bypass this check,
e.g. if we know that the operation has already been successfully
validated in another context. *)valvalidate_operation:?check_signature:bool->validation_state->Operation_hash.t->operation->validation_statetzresultLwt.t(** Run final and global checks on the block that must come after
the validation of all its operations to establish its
validity. *)valfinalize_validation:validation_state->unittzresultLwt.t(** Initialize the {!application_state} for the application process
of an existing or new block. See {!begin_validation} for details
on the arguments.
In protocol versions > K, calling this function with the
{!Partial_validation} mode returns an error. *)valbegin_application:Context.t->Chain_id.t->mode->predecessor:Block_header.shell_header->application_statetzresultLwt.t(** Apply an operation. If successful, return the updated
{!application_state} and the corresponding {!operation_receipt}.
This should be called for all operations in a block, after
{!begin_application} and before
{!finalize_application}. Moreover, the operation should have
already been validated by {!validate_operation}. *)valapply_operation:application_state->Operation_hash.t->operation->(application_state*operation_receipt)tzresultLwt.t(** Finalize the context resulting from the application of the
contents of the block.
If there is no protocol migration, i.e. if the block being
applied is not the last block of the current economic protocol,
then the resulting context can be used in the future as input for
the validation and application of its successor blocks.
In {!Construction} mode, the [Block_header.shell_header option]
argument must contain a value, which will be used to compute the
[cache_nonce]. In other modes, it can as well be [None] since it
will not be used. *)valfinalize_application:application_state->Block_header.shell_headeroption->(validation_result*block_header_metadata)tzresultLwt.t(** [rpc_services] provides the list of remote procedures exported
by this protocol implementation. *)valrpc_services:rpc_contextRPC_directory.t(** [init chain_id ctxt hd] initializes the context, or upgrades the
context after a protocol amendment. This function receives as
arguments the [chain_id] of the current chain and the context
[ctxt] resulting from the application of the block that triggered
the amendment, as well as its header [hd]. This function should
fail if the "protocol stitching", i.e., the transition from a
valid previous protocol to the one being activated, has not been
implemented. *)valinit:Chain_id.t->Context.t->Block_header.shell_header->validation_resulttzresultLwt.t(** [value_of_key chain_id predecessor_context
predecessor_timestamp predecessor_level predecessor_fitness
predecessor timestamp] returns a function to build one value of
the cache from its key.
This function is used to restore all or part of the cache, for
instance when booting a validator to preheat the cache, or when a
reorganization happens. This function should never fail, returned
errors are fatal.
The generated function is passed to [Context.Cache.load_caches]
which will use it either immediately a cache-loading time or
on-demand, when a given cached value is accessed. *)valvalue_of_key:chain_id:Chain_id.t->predecessor_context:Context.t->predecessor_timestamp:Time.t->predecessor_level:Int32.t->predecessor_fitness:Fitness.t->predecessor:Block_hash.t->timestamp:Time.t->(Context.Cache.key->Context.Cache.valuetzresultLwt.t)tzresultLwt.tmoduleMempool:sig(** Mempool type. This immutable functional state keeps track of
operations added to the mempool, and allows to detect conflicts
between them and a new candidate operation. *)typet(** Validation info type required to validate and add operations to a
mempool. *)typevalidation_info(** Type of the function that may be provided in order to resolve a
potential conflict when adding an operation to an existing mempool
or when merging two mempools. This handler may be defined as a
simple order relation over operations (e.g. prioritize the most
profitable operations) or an arbitrary one (e.g. prioritize
operations where the source is a specific manager).
Returning [`Keep] will leave the mempool unchanged and retain the
[existing_operation] while returning [`Replace] will remove
[existing_operation] and add [new_operation] instead. *)typeconflict_handler=existing_operation:Operation_hash.t*operation->new_operation:Operation_hash.t*operation->[`Keep|`Replace]typeoperation_conflict=|Operation_conflictof{existing:Operation_hash.t;new_operation:Operation_hash.t;}(** Return type when adding an operation to the mempool *)typeadd_result=|Added(** [Added] means that an operation was successfully added to
the mempool without any conflict. *)|Replacedof{removed:Operation_hash.t}(** [Replaced {removed}] means that an operation was
successfully added but there was a conflict with the [removed]
operation which was removed from the mempool. *)|Unchanged(** [Unchanged] means that there was a conflict with an existing
operation which was considered better by the
[conflict_handler], therefore the new operation is discarded
and the mempool remains unchanged.*)(** Error type returned when adding an operation to the mempool fails. *)typeadd_error=|Validation_erroroferrortrace(** [Validation_error _] means that the operation is invalid. *)|Add_conflictofoperation_conflict(** [Add_conflict _] means that an operation conflicts with
an existing one. This error will only be obtained when
no [conflict_handler] was provided. Moreover,
[Validation_error _] takes precedence over [Add_conflict
_] which implies that we have the implicit invariant
that the operation would be valid if there was no
conflict. Therefore, if [add_operation] would have to be
called again, it would be redondant to check the
operation's signature. *)(** Error type returned when the merge of two mempools fails. *)typemerge_error=|Incompatible_mempool(** [Incompatible_mempool _] means that the two mempools are not built
ontop of the same head and therefore cannot be considered. *)|Merge_conflictofoperation_conflict(** [Merge_conflict _] arises when two mempool contains conflicting
operations and no [conflict_handler] was provided.*)(** Initialize a static [validation_info] and [mempool], required
to validate and add operations, and an incremental and
serializable {!mempool}. *)valinit:Context.t->Chain_id.t->head_hash:Block_hash.t->head:Block_header.shell_header->(validation_info*t)tzresultLwt.t(** Mempool encoding *)valencoding:tData_encoding.t(** Adds an operation to a [mempool] if and only if it is valid and
does not conflict with previously added operation.
This function checks the validity of an operation and tries to
add it to the mempool.
If a validation error is triggered, the result will be a
[Validation_error]. If a conflict with a previous operation
exists, the result will be [Add_conflict] is then checked.
Important: no [Add_conflict] will be raised if a
[conflict_handler] is provided (see [add_result]).
If no error is raised the operation is potentially added to the
[mempool] depending on the [add_result] value. *)valadd_operation:?check_signature:bool->?conflict_handler:conflict_handler->validation_info->t->Operation_hash.t*operation->(t*add_result,add_error)resultLwt.t(** [remove_operation mempool oph] removes the operation [oph] from
the [mempool]. The [mempool] remains unchanged when [oph] is not
present in the [mempool] *)valremove_operation:t->Operation_hash.t->t(** [merge ?conflict_handler mempool mempool'] merges [mempool']
{b into} [mempool].
Mempools may only be merged if they are compatible: i.e. both have
been initialised with the same predecessor block. Otherwise, the
[Incompatible_mempool] error is returned.
Conflicts between operations from the two mempools can
occur. Similarly as [add_operation], a [Merge_conflict] error
may be raised when no [conflict_handler] is provided.
[existing_operation] in [conflict_handler ~existing_operation ~new_operation]
references operations present in [mempool] while
[new_operation] will reference operations present in
[mempool']. *)valmerge:?conflict_handler:conflict_handler->t->t->(t,merge_error)result(** [operations mempool] returns the map of operations present in
[mempool]. *)valoperations:t->operationOperation_hash.Map.tendend(** [activate ctxt ph] activates an economic protocol (given by its
hash [ph]) from the context [ctxt]. The resulting context is still
a context for the current economic protocol, and the migration is
not complete until [init] in invoked. *)valactivate:Context.t->Protocol_hash.t->Context.tLwt.tend# 128 "v8.in.ml"moduleRPC_context:sig# 1 "v8/RPC_context.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)typet=Updater.rpc_contextclasstype['pr]simple=objectmethodcall_proto_service0:'m'q'i'o.(([<RPC_service.meth]as'm),t,t,'q,'i,'o)RPC_service.t->'pr->'q->'i->'oError_monad.shell_tzresultLwt.tmethodcall_proto_service1:'m'a'q'i'o.(([<RPC_service.meth]as'm),t,t*'a,'q,'i,'o)RPC_service.t->'pr->'a->'q->'i->'oError_monad.shell_tzresultLwt.tmethodcall_proto_service2:'m'a'b'q'i'o.(([<RPC_service.meth]as'm),t,(t*'a)*'b,'q,'i,'o)RPC_service.t->'pr->'a->'b->'q->'i->'oError_monad.shell_tzresultLwt.tmethodcall_proto_service3:'m'a'b'c'q'i'o.(([<RPC_service.meth]as'm),t,((t*'a)*'b)*'c,'q,'i,'o)RPC_service.t->'pr->'a->'b->'c->'q->'i->'oError_monad.shell_tzresultLwt.tendvalmake_call0:([<RPC_service.meth],t,t,'q,'i,'o)RPC_service.t->'pr#simple->'pr->'q->'i->'oshell_tzresultLwt.tvalmake_call1:([<RPC_service.meth],t,t*'a,'q,'i,'o)RPC_service.t->'pr#simple->'pr->'a->'q->'i->'oshell_tzresultLwt.tvalmake_call2:([<RPC_service.meth],t,(t*'a)*'b,'q,'i,'o)RPC_service.t->'pr#simple->'pr->'a->'b->'q->'i->'oshell_tzresultLwt.tvalmake_call3:([<RPC_service.meth],t,((t*'a)*'b)*'c,'q,'i,'o)RPC_service.t->'pr#simple->'pr->'a->'b->'c->'q->'i->'oshell_tzresultLwt.tvalmake_opt_call0:([<RPC_service.meth],t,t,'q,'i,'o)RPC_service.t->'pr#simple->'pr->'q->'i->'ooptionshell_tzresultLwt.tvalmake_opt_call1:([<RPC_service.meth],t,t*'a,'q,'i,'o)RPC_service.t->'pr#simple->'pr->'a->'q->'i->'ooptionshell_tzresultLwt.tvalmake_opt_call2:([<RPC_service.meth],t,(t*'a)*'b,'q,'i,'o)RPC_service.t->'pr#simple->'pr->'a->'b->'q->'i->'ooptionshell_tzresultLwt.tvalmake_opt_call3:([<RPC_service.meth],t,((t*'a)*'b)*'c,'q,'i,'o)RPC_service.t->'pr#simple->'pr->'a->'b->'c->'q->'i->'ooptionshell_tzresultLwt.tend# 130 "v8.in.ml"moduleWasm_2_0_0:sig# 1 "v8/wasm_2_0_0.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2022 Trili Tech <contact@trili.tech> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)typeinput={inbox_level:Bounded.Non_negative_int32.t;message_counter:Z.t}typeoutput={outbox_level:Bounded.Non_negative_int32.t;message_index:Z.t}typereveal_hash=stringtypereveal=Reveal_raw_dataofreveal_hash|Reveal_metadatatypeinput_request=|No_input_required|Input_required|Reveal_requiredofrevealtypeinfo={current_tick:Z.t;last_input_read:inputoption;input_request:input_request;}moduleMake(Tree:Context.TREEwithtypekey=stringlistandtypevalue=bytes):sigvalinitial_state:Tree.tree->Tree.treeLwt.tvalinstall_boot_sector:ticks_per_snapshot:Z.t->outbox_validity_period:int32->outbox_message_limit:Z.t->string->Tree.tree->Tree.treeLwt.tvalcompute_step:Tree.tree->Tree.treeLwt.tvalset_input_step:input->string->Tree.tree->Tree.treeLwt.tvalreveal_step:bytes->Tree.tree->Tree.treeLwt.tvalget_output:output->Tree.tree->stringoptionLwt.tvalget_info:Tree.tree->infoLwt.tendend# 132 "v8.in.ml"modulePlonk:sig# 1 "v8/plonk.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(**
aPlonK is a {e PlonK}-based proving system.
As such, it provides a way to create {e succinct cryptographic proofs}
about a given predicate, which can be then verified with a low
computational cost.
In this system, a predicate is represented by an {e arithmetic circuit},
i.e. a collection of arithmetic {e gates} operating over a {e prime field},
connected through {e wires} holding {e scalars} from this field.
For example, the following diagram illustrates a simple circuit checking that
the addition of two scalars ([w1] and [w2]) is equal to [w0]. Here,
the [add] gate can be seen as taking two inputs and producing an output,
while the [eq] gate just takes two inputs and asserts they're equal.
{[
(w0)│ w1│ w2│
│ └───┐ ┌───┘
│ ┌─┴───┴─┐
│ │ add │
│ └───┬───┘
└──────┐ ┌───┘w3
┌─┴───┴─┐
│ eq │
└───────┘
]}
The wires of a circuit are called {e prover inputs}, since the prover needs
an assignment of all wires to produce a proof.
The predicate also declares a subset of the wires called {e verifier inputs}.
In our example, wire [w0] is the only verifier input, which is
indicated by the parenthesis.
A proof for a given [w0] would prove the following statement:
[∃ w1, w2, w3: w3 = w1 + w2 ∧ w0 = w3]
This means that the verifier only needs a (typically small) subset of the
inputs alongside the (succinct) proof to check the validity of the statement.
A more interesting example would be to replace the [add] gate
by a more complicated hash circuit. This would prove the knowledge of the
pre-image of a hash.
A simplified view of aPlonk's API consists of the following three functions:
{[
val setup : circuit -> srs ->
(prover_public_parameters, verifier_public_parameters)
val prove : prover_public_parameters -> prover_inputs ->
private_inputs -> proof
val verify : verifier_public_parameters -> verifier_inputs ->
proof -> bool
]}
In addition to the prove and verify, the interface provides a function
to setup the system. The setup function requires a {e Structured Reference String}.
Two large SRSs were generated by the ZCash and Filecoin
projects and are both used in aPlonK.
Notice also that the circuit is used during setup only and, independently
from its size, the resulting {e verifier_public_parameters} will be a
succinct piece of data that will be posted on-chain to allow
verification and they are bound to the specific circuit that generated
them.
The {e prover_public_parameters}'s size is linear in the size of the circuit.
*)typescalar:=Bls.Primitive.Fr.t(** Set of public parameters needed by the verifier.
Its size is constant w.r.t. the size of the circuits. *)typepublic_parameters(** Map where each circuit identifier is bound to the verifier inputs for
this circuit. *)typeverifier_inputs=(string*scalararraylist)list(** Succinct proof for a collection of statements. *)typeproofvalpublic_parameters_encoding:public_parametersData_encoding.tvalproof_encoding:proofData_encoding.tvalscalar_encoding:scalarData_encoding.tvalscalar_array_encoding:scalararrayData_encoding.t(** [verify public_parameters inputs proof] returns true if the [proof] is valid
on the given [inputs] according to the [public_parameters]. *)valverify:public_parameters->verifier_inputs->proof->boolend# 134 "v8.in.ml"moduleDal:sig# 1 "v8/dal.mli"(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** A precomputed set of constants *)typet(** Parameters to build a value of type [t] *)typeparameters={redundancy_factor:int;page_size:int;slot_size:int;number_of_shards:int;}(** An encoding for values of type {!type-parameters}. *)valparameters_encoding:parametersData_encoding.t(** [make] precomputes the set of values needed by cryptographic primitives
defined in this module and store them in a value of type [t] *)valmake:parameters->(t,[>`Failofstring])result(** [parameters t] returns the parameters given when [t] was
initialised with the function {!val:make} *)valparameters:t->parameters(** Commitment to a polynomial. *)typecommitmentmoduleCommitment:sig(** An encoding for a commitment. *)valencoding:commitmentData_encoding.t(** [to_b58check commitment] returns a b58 representation
of [commitment]. *)valto_b58check:commitment->string(** [of_b58check_opt bytes] computes a commitment from
its b58 representation. Returns [None] if it is not a valid
representation. *)valof_b58check_opt:string->commitmentoptionvalzero:commitmentvalequal:commitment->commitment->boolvalpp:Format.formatter->commitment->unitend(** A proof that the polynomial associated to some commitment is
bounded by a constant. *)typecommitment_proofmoduleCommitment_proof:sig(** An encoding for a commitment proof. *)valencoding:commitment_proofData_encoding.tvalzero:commitment_proofend(** [verify_commitment srs commitment proof] checks whether
[commitment] is a valid [commitment]. In particular, it check
that the size of the data committed via [commitment] do not
exceed [C.slot_size]. The verification time is constant. *)valverify_commitment:t->commitment->commitment_proof->bool(** The original slot can be split into a list of pages of fixed
size. This size is given by the parameter [page_size] given to the
function {!val:make}. *)typepage=bytes(** A proof that the evaluation of points of a polynomial is part of
a commitment. *)typepage_proof(** An encoding for the proof of a page. *)valpage_proof_encoding:page_proofData_encoding.t(** [pages_per_slot t] returns the number of expected pages per slot. *)valpages_per_slot:parameters->int(** [verify_page t srs commitment page page_proof] returns [Ok true]
if the [proof] certifies that the [slot_page] is indeed included
in the slot committed with commitment [commitment]. Returns [Ok
false] otherwise.
Fails if the index of the page is out of range or if the page is
not of the expected length [page_size] given for the
initialisation of [t]. *)valverify_page:t->commitment->page_index:int->page->page_proof->(bool,[>`Segment_index_out_of_range|`Page_length_mismatch])Result.tend# 136 "v8.in.ml"end