parse: deprecate try_, rename new function try_opt

This commit is contained in:
Simon Cruanes 2021-05-12 09:20:31 -04:00
parent 0ec40c2331
commit 171b4ddcd9
2 changed files with 12 additions and 2 deletions

View file

@ -457,7 +457,9 @@ let fix f =
and f_self = lazy (f self) in
self
let try_ p : _ t = {
let try_ p = p
let try_opt p : _ t = {
run=fun st ~ok ~err:_ ->
p.run st
~ok:(fun st x -> ok st (Some x))

View file

@ -229,7 +229,15 @@ val optional : _ t -> unit t
succeeded or failed. Cannot fail.
@since NEXT_RELEASE *)
val try_ : 'a t -> 'a option t
val try_ : 'a t -> 'a t
(** [try_ p] is just like [p] (it used to play a role in backtracking
semantics but no more).
@deprecated since NEXT_RELEASE it can just be removed. See {!try_opt} if you want
to detect failure. *)
[@@deprecated "plays no role anymore"]
val try_opt : 'a t -> 'a option t
(** [try_ p] tries to parse using [p], and return [Some x] if [p]
succeeded with [x]. Otherwise it returns [None]. This cannot fail.
@since NEXT_RELEASE *)