123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119moduleImpl:Meta.Swithtype'at='aAngstrom.t=structtype'at='aAngstrom.tlet(<$>)bijectionp=letopenAngstrominp>>=funx->tryletx=bijection.Bijection.to_xinreturnxwithBijection.Exn.Bijection(to_,of_)->Angstrom.fail(Fmt.strf"bijection: %s to %s"to_of_)let(<*>)papb=letopenAngstrominpa>>=funa->pb>>=funb->return(a,b)let(<|>)pupv=letopenAngstrominpu<|>pvlet(*>)pupe=letopenAngstrominpu*>pelet(<*)pepu=letopenAngstrominpe<*pulet($>):unitt->(unit,'a)Bijection.texn->'at=funpubijection->letopenAngstrominpu>>=fun()->letopenBijectioninmatch(bijection.to_(),bijection.kd)with|x,E->returnx|exceptionBijection.Exn.Bijection(to_,of_)->Angstrom.fail(Fmt.strf"bijection: %s to %s"to_of_)let(<$):'at->(unit,'a)Bijection.texn->unitt=funpebijection->letopenAngstrominpe>>=funx->letopenBijectioninmatch(bijection.of_x,bijection.kd)with|x,E->returnx|exceptionBijection.Exn.Bijection(to_,of_)->Angstrom.fail(Fmt.strf"bijection: %s to %s"to_of_)letfix=Angstrom.fixletnop=Angstrom.return()letany=Angstrom.any_charletfailerr=Angstrom.failerrletpure~compare:_v=Angstrom.returnvlettake=Angstrom.takeletpeekab=letopenAngstrominpeek_char>>=function|Some_->a>>|funx->Either.Lx|None->b>>|funy->Either.Ryletskip=Angstrom.skip_manyletconsts=Angstrom.(strings<?>s)letcommit=Angstrom.commitletwhile0=Angstrom.take_whileletwhile1=Angstrom.take_while1letbigstring_while0=Angstrom.take_bigstring_whileletbigstring_while1=Angstrom.take_bigstring_while1letbuffer=letopenAngstrominavailable>>=takeletbigstring_buffer=letopenAngstrominavailable>>=take_bigstringmoduleOption=structlet(<$>)bijectionp=letopenAngstrominp>>=funx->matchbijection.Bijection.to_xwith|Somex->returnx|None->Angstrom.fail"bijection: 'a to 'b"let($>)pubijection=letopenAngstrominpu>>=fun()->letopenBijectioninmatch(bijection.to_(),bijection.kd)with|Somex,O->returnx|None,O->Angstrom.fail"bijection: unit to 'a"let(<$)pebijection=letopenAngstrominpe>>=funx->letopenBijectioninmatch(bijection.of_x,bijection.kd)with|Somex,O->returnx|None,O->Angstrom.fail"bijection: 'a to unit"endend