1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192moduletypeCUSTOM=sigtypetvalt:tCaqti_type.tend(* Derived from implementation of List.group in Base.
Original code is copyright (c) 2016--2020 Jane Street Group, LLC opensource@janestreet.com
and the following permission notice applies to it:
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. *)letlist_groupl~break=letgroups=List.fold_left(funaccx->matchaccwith|[]->[[x]]|current_group::tl->ifbreak(List.hdcurrent_group)xthen[x]::current_group::tl(* start new group *)else(x::current_group)::tl)[]l(* extend current group *)inmatchgroupswith[]->[]|l->List.rev_mapList.revlletload_many(get_parent,parent_key)children_getters_and_settersdata=data|>list_group~break:(funxy->parent_key(get_parentx)<>parent_key(get_parenty))|>List.map(fungroup->letparents,children=(List.mapget_parentgroup,List.map(fun(getter,setter)->(setter,List.mapgettergroup))children_getters_and_setters)inletparent=List.hdparentsinList.fold_left(funcurrent_parent(setter,children)->settercurrent_parentchildren)parentchildren)moduleInternal=structmoduleDynparam=structtypet=Pack:'aCaqti_type.t*'a->tletempty=Pack(Caqti_type.unit,())letaddtx(Pack(t',x'))=Pack(Caqti_type.tup2t't,(x',x))endendmoduletypeIO=sigtype+'atvalreturn:'a->'atvalmap:('a->'b)->'at->'bt(* Need this for Caqti_connection_sig.S *)moduleStream:Caqti_stream.Swithtype'afuture:='atendmoduletypeRAPPER_HELPER=sigtype+'afuturevalmap:('a->'b)->'afuture->'bfuturevalfail:'e->('a,'e)resultfuturemoduleStream:Caqti_stream.Swithtype'afuture:='afuturemoduletypeCONNECTION=Caqti_connection_sig.Swithtype'afuture:='afutureandtype('a,'err)stream:=('a,'err)Stream.tendmoduleMake_helper(Io:IO):RAPPER_HELPERwithtype'afuture:='aIo.tandmoduleStream=Io.Stream=structletmap=Io.mapletfaile=Io.return(Errore)moduleStream=Io.StreammoduletypeCONNECTION=Caqti_connection_sig.Swithtype'afuture:='aIo.tandtype('a,'err)stream:=('a,'err)Stream.tend