12345678910111213141516171819202122232425262728293031323334353637383940414243letgetExn=function|Somex->x|None->leterror=Printf.sprintf"File %s, line %d"__FILE____LINE__inJs.Exn.raiseErrorerrorletmapWithDefaultUoptdefaultf=matchoptwithSomex->fx|None->defaultletmapWithDefaultoptdefaultf=mapWithDefaultUoptdefault(funx->fx)letmapUoptf=matchoptwithSomex->Some(fx)|None->Noneletmapoptf=mapUopt(funx->fx)letflatMapUoptf=matchoptwithSomex->fx|None->NoneletflatMapoptf=flatMapUopt(funx->fx)letgetWithDefaultoptdefault=matchoptwithSomex->x|None->defaultletisSome=functionSome_->true|None->falseletisNone=functionSome_->false|None->trueleteqUabf=match(a,b)with|Somea,Someb->fab|None,Some_|Some_,None->false|None,None->trueleteqabf=eqUab(funxy->fxy)letcmpUabf=match(a,b)with|Somea,Someb->fab|None,Some_->-1|Some_,None->1|None,None->0letcmpabf=cmpUab(funxy->fxy)letkeepUoptf=matchoptwithSomexwhenfx->opt|Some_|None->Noneletkeepoptf=keepUopt(funx->fx)letforEachUoptf=matchoptwithSomex->fx|None->()letforEachoptf=forEachUopt(funx->fx)externalgetUnsafe:'aoption->'a="%identity"