Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file error.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121(*Generated by Lem from error.lem.*)openLem_basic_classesopenLem_listopenLem_maybeopenLem_numopenLem_stringopenShow(** [error] is a type used to represent potentially failing computations. [Success]
* marks a successful completion of a computation, whilst [Fail err] marks a failure,
* with [err] as the reason.
*)type'aerror=Successof'a|Failofstring(** [return] is the monadic lifting function for [error], representing a successful
* computation.
*)(*val return : forall 'a. 'a -> error 'a*)letreturnr:'aerror=(Successr)(*val with_success : forall 'a 'b. error 'a -> 'b -> ('a -> 'b) -> 'b*)letwith_successerrflsuc:'b=((matcherrwith|Successs->sucs|Failerr->fl))(** [fail err] represents a failing computation, with error message [err].
*)(*val fail : forall 'a. string -> error 'a*)letfailerr:'aerror=(Failerr)(** [(>>=)] is the monadic binding function for [error].
*)(*val >>= : forall 'a 'b. error 'a -> ('a -> error 'b) -> error 'b*)letbindxf:'berror=((matchxwith|Successs->fs|Failerr->Failerr))(** [as_maybe e] drops an [error] value into a [maybe] value, throwing away
* error information.
*)(*val as_maybe : forall 'a. error 'a -> maybe 'a*)letas_maybee:'aoption=((matchewith|Failerr->None|Successs->Somes))(*val of_maybe : forall 'a. string -> maybe 'a -> error 'a*)letof_maybeerr_msgm:'aerror=((matchmwith|Somev->Successv|None->Failerr_msg))(** [repeatM count action] fails if [action] is a failing computation, or
* successfully produces a list [count] elements long, where each element is
* the value successfully returned by [action].
*)(*val repeatM'' : forall 'a. natural -> error 'a -> error (list 'a) -> error (list 'a)*)letrecrepeatM''countactionacc:('alist)error=(ifNat_big_num.equalcount((Nat_big_num.of_int0))thenaccelserepeatM''(Nat_big_num.sub_natcount((Nat_big_num.of_int1)))action(bindacc(funtail->bindaction(funhead->return(head::tail)))))(*val repeatM : forall 'a. natural -> error 'a -> error (list 'a)*)letrepeatMcountaction:('alist)error=(repeatM''countaction(return[]))(** [repeatM' count seed action] is a variant of [repeatM] that acts like [repeatM]
* apart from any successful result returns a tuple whose second component is [seed]
* and whose first component is the same as would be returned by [repeatM].
*)(*val repeatM' : forall 'a 'b. natural -> 'b -> ('b -> error ('a * 'b)) -> error ((list 'a) * 'b)*)letrecrepeatM'countseedaction:('alist*'b)error=(ifNat_big_num.equalcount((Nat_big_num.of_int0))thenreturn([],seed)elsebind(actionseed)(fun(head,seed)->bind(repeatM'(Nat_big_num.sub_natcount((Nat_big_num.of_int1)))seedaction)(fun(tail,seed)->return((head::tail),seed))))(** [mapM f xs] maps [f] across [xs], failing if [f] fails on any element of [xs].
*)(*val mapM' : forall 'a 'b. ('a -> error 'b) -> list 'a -> error (list 'b) -> error (list 'b)*)letrecmapM'fxsrev_acc:('blist)error=((matchxswith|[]->bindrev_acc(funrev_acc->return(List.revrev_acc))|x::xs->mapM'fxs(bindrev_acc(funtl->bind(fx)(funhd->return(hd::tl))))))(*val mapM : forall 'a 'b. ('a -> error 'b) -> list 'a -> error (list 'b)*)letmapMfxs:('blist)error=(mapM'fxs(return[]))(** [foldM f e xs] performs a monadic right fold of [f] across [xs] using [e]
* as the base case. Fails if any application of [f] fails.
*)(*val foldM : forall 'a 'b. ('a -> 'b -> error 'a) -> 'a -> list 'b -> error 'a*)letrecfoldMfexs:'aerror=((matchxswith|[]->returne|x::xs->bind(fex)(funres->foldMfresxs)))(** [string_of_error err] produces a string representation of [err].
*)(*val string_of_error : forall 'a. Show 'a => error 'a -> string*)letstring_of_errordict_Show_Show_ae:string=((matchewith|Failerr->"Fail: "^err|Successs->dict_Show_Show_a.show_methods))letinstance_Show_Show_Error_error_dictdict_Show_Show_a:('aerror)show_class=({show_method=(string_of_errordict_Show_Show_a)})