ResA result for some computation. Ok or Error of Format.formatter
The following functions have been taken from (future) 4.09 Stdlib.Result. * These 5 functions, ok, error, bind, join and map should be removed * after the Stdlib upgrade.
bind r f is f v if r is Ok v and r if r is Error _.
join rr is r if rr is Ok r and rr if rr is Error _.
map f r is Ok (f v) if r is Ok v and r if r is Error _.
Infix version of bind
Disregards the output of the first computation
sequences a list of result into a result of list * basically errors out on first error or returns the whole value list
Chains the output of the head computation into the following tail computation while folding
Folds a list under a result type
general case of seq_
sequences a list of unit into a result of unit * errors out on first error or returns a unit
val ifM :
(bool, 'e) Stdlib.result ->
('a, 'e) Stdlib.result ->
('a, 'e) Stdlib.result ->
('a, 'e) Stdlib.resultThis is an if .. then .. else lifted in monadic world
converts a monadic boolean condition into a guard
Unwrap the result value and return the default value if it is an error
val unwrap : 'a res -> 'aUnwraps a result.
Maps functions to Ok or Err.
Maps a function to a result if it's Err.
val chain :
?fmt:((Stdlib.Format.formatter -> unit) -> Stdlib.Format.formatter -> unit) ->
('a -> 'b res) ->
'a res ->
'b resFeeds a result to a function returning a result, propagates if argument's an error.
val l_fold :
?fmt:((Stdlib.Format.formatter -> unit) -> Stdlib.Format.formatter -> unit) ->
('acc -> 'a -> 'acc res) ->
'acc ->
'a list ->
'acc resFold over a list of results.