12345678910111213141516171819202122232425262728293031323334353637383940414243444546(**************************************************************************)(* *)(* OCaml *)(* *)(* The OCaml programmers *)(* *)(* Copyright 2018 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. *)(* *)(**************************************************************************)type('a,'e)t=('a,'e)result=Okof'a|Errorof'eletokv=Okvleterrore=Erroreletvaluer~default=matchrwithOkv->v|Error_->defaultletget_ok=functionOkv->v|Error_->invalid_arg"result is Error _"letget_error=functionErrore->e|Ok_->invalid_arg"result is Ok _"letbindrf=matchrwithOkv->fv|Error_ase->eletjoin=functionOkr->r|Error_ase->eletmapf=functionOkv->Ok(fv)|Error_ase->eletmap_errorf=functionErrore->Error(fe)|Ok_asv->vletfold~ok~error=functionOkv->okv|Errore->erroreletiterf=functionOkv->fv|Error_->()letiter_errorf=functionErrore->fe|Ok_->()letis_ok=functionOk_->true|Error_->falseletis_error=functionError_->true|Ok_->falseletequal~ok~errorr0r1=matchr0,r1with|Okv0,Okv1->okv0v1|Errore0,Errore1->errore0e1|_,_->falseletcompare~ok~errorr0r1=matchr0,r1with|Okv0,Okv1->okv0v1|Errore0,Errore1->errore0e1|Ok_,Error_->-1|Error_,Ok_->1letto_option=functionOkv->Somev|Error_->Noneletto_list=functionOkv->[v]|Error_->[]letto_seq=functionOkv->Seq.returnv|Error_->Seq.empty