123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384(*
* Copyright (c) 2013-2017 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.
*)moduleMake(Contents:S.CONTENTS_STORE)(Node:S.NODE_STORE)(Commit:S.COMMIT_STORE)=structtypecontents=Contents.key*Contents.valuetypenode=Node.key*Node.valuetypecommit=Commit.key*Commit.valuetypevalue=[`Contentsofcontents|`Nodeofnode|`Commitofcommit]typet={mutablecontents:(Contents.key*Contents.value)list;mutablenodes:(Node.key*Node.value)list;mutablecommits:(Commit.key*Commit.value)list;}lett=letopenTypeinrecord"slice"(funcontentsnodescommits->{contents;nodes;commits})|+field"contents"(list(pairContents.Key.tContents.Val.t))(funt->t.contents)|+field"nodes"(list(pairNode.Key.tNode.Val.t))(funt->t.nodes)|+field"commits"(list(pairCommit.Key.tCommit.Val.t))(funt->t.commits)|>sealrletempty()=Lwt.return{contents=[];nodes=[];commits=[]}letaddt=function|`Contentsc->t.contents<-c::t.contents;Lwt.return_unit|`Noden->t.nodes<-n::t.nodes;Lwt.return_unit|`Commitc->t.commits<-c::t.commits;Lwt.return_unitletitertf=Lwt.join[Lwt_list.iter_p(func->f(`Contentsc))t.contents;Lwt_list.iter_p(funn->f(`Noden))t.nodes;Lwt_list.iter_p(func->f(`Commitc))t.commits;]letcontents_t=Type.pairContents.Key.tContents.Val.tletnode_t=Type.pairNode.Key.tNode.Val.tletcommit_t=Type.pairCommit.Key.tCommit.Val.tletvalue_t=letopenTypeinvariant"slice"(funcontentsnodecommit->function|`Contentsx->contentsx|`Nodex->nodex|`Commitx->commitx)|~case1"contents"contents_t(funx->`Contentsx)|~case1"node"node_t(funx->`Nodex)|~case1"commit"commit_t(funx->`Commitx)|>sealvend