Module Pulselib.PulseResult

type ('ok, 'err) t =
  1. | Ok of 'ok
  2. | Recoverable of 'ok * 'err list
  3. | FatalError of 'err * 'err list

Pulse's base error monad: some errors can be accumulated along paths, others are fatal and there's no point continuing the execution.

val append_errors : 'err list -> ('ok, 'err) t -> ('ok, 'err) t

adds the given error list to the result, possibly changing an Ok result into a Recoverable one in the process

val ok : ('ok, _) t -> 'ok option
val ok_exn : ('ok, _) t -> 'ok

dies if the argument is not of the form Ok _

val map : ('ok, 'err) t -> f:('ok -> 'okk) -> ('okk, 'err) t
val map_error : ('ok, 'err) t -> f:('err -> 'err') -> ('ok, 'err') t
val bind : ('ok, 'err) t -> f:('ok -> ('okk, 'err) t) -> ('okk, 'err) t
val join : (('ok, 'err) t, 'err) t -> ('ok, 'err) t

Interaction with other datatypes

val of_some : ('ok option, 'err) t -> ('ok, 'err) t option
val recoverable_of_result : ok_of_error:('err -> 'ok) -> ('ok, 'err) IStdlib.IStd.result -> ('ok, 'err) t

changes Result.Error to Recoverable using ok_of_error

val fatal_of_result : ('ok, 'err) IStdlib.IStd.result -> ('ok, 'err) t

changes Result.Error to FatalError

val to_result : ('ok, 'err) t -> ('ok, 'err list) IStdlib.IStd.result

Recoverable and FatalError are both sent to Error

val list_fold : 'a list -> init:'ok -> f:('ok -> 'a -> ('ok, 'err) t) -> ('ok, 'err) t
val list_fold2 : 'a list -> 'b list -> init:'ok -> f:('ok -> 'a -> 'b -> ('ok, 'err) t) -> ('ok, 'err) t IStdlib.IStd.List.Or_unequal_lengths.t
val list_foldi : init:'acc -> f:(int -> 'acc -> 'a -> ('acc, 'err) t) -> 'a list -> ('acc, 'err) t
val container_fold : fold:('t, 'a, ('accum, 'err) t) IStdlib.IStd.Container.fold -> 't -> init:'accum -> f:('accum -> 'a -> ('accum, 'err) t) -> ('accum, 'err) t
module Type : sig ... end

for opening locally

module Monad_infix : sig ... end
module Let_syntax : sig ... end