12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667(**************************************************************************)(* *)(* 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'at='aoption=None|Someof'aletnone=Noneletsomev=Somevletvalueo~default=matchowithSomev->v|None->defaultletget=functionSomev->v|None->invalid_arg"option is None"letbindof=matchowithNone->None|Somev->fvletjoin=functionSomeo->o|None->Noneletmapfo=matchowithNone->None|Somev->Some(fv)letproducto0o1=matcho0,o1with|None,_|_,None->None|Somev0,Somev1->Some(v0,v1)letfold~none~some=functionSomev->somev|None->noneletiterf=functionSomev->fv|None->()letis_none=functionNone->true|Some_->falseletis_some=functionNone->false|Some_->trueletblendfo1o2=matcho1,o2with|None,None->None|(Some_asx),None|None,(Some_asx)->x|Somev1,Somev2->Some(fv1v2)letequaleqo0o1=matcho0,o1with|Somev0,Somev1->eqv0v1|None,None->true|_->falseletcomparecmpo0o1=matcho0,o1with|Somev0,Somev1->cmpv0v1|None,None->0|None,Some_->-1|Some_,None->1letfor_allp=function|None->true|Somev->pvletexistsp=function|None->false|Somev->pvletto_result~none=functionNone->Errornone|Somev->Okvletto_list=functionNone->[]|Somev->[v]letto_seq=functionNone->Seq.empty|Somev->Seq.returnvmoduleSyntax=structlet(let*)=bindlet(and*)=productlet(let+)of=mapfolet(and+)=productend