Module Accessor.Of_monad
Of_monad
is similar to Of_applicative
. There are two differences.
Many functions generated by Of_monad
can distinguish between `Sequential
traversals and `Parallel
traversals. This matters when you want to use monadic sequencing to control side effects. The functions generated by Of_applicative
are only able to use the `Parallel
behavior. Here are a couple examples of when you might care about this:
- When using
Or_error
,map ~how:`Sequential t at ~f
would terminate the traversal as soon as an error has occurs.map ~how:`Parallel t at ~f
would applyf
to everything before attempting to compose the results, and if there is more than one error they will be combined. - When using
Deferred
,map ~how:`Sequential t at ~f
would wait for each deferred to become determined before moving on to the next value.map ~how:`Parallel at ~f
would applyf
to everything and then wait for the results to become determined asynchronously.
Parameters
M : sig ... end
Signature
include Accessor__.Applicative_signatures_intf.Monad_s2 with type ('a, _) t := 'a t
val map : ((Base.unit -> 'a -> 'b, Base.unit -> 'at -> 'bt, [> Subtyping.many ]) accessor -> 'at -> f:('a -> ('b, 'e) t) -> ('bt, 'e) t) optional_args
val mapi : (('i -> 'a -> 'b, Base.unit -> 'at -> 'bt, [> Subtyping.many ]) accessor -> 'at -> f:('i Index.t -> 'a -> ('b, 'e) t) -> ('bt, 'e) t) optional_args
val all : (Base.unit -> ('a, 'e) t -> 'a, Base.unit -> 'at -> 'bt, [> Subtyping.many ]) accessor -> 'at -> ('bt, 'e) t
val all_unit : (Base.unit -> (Base.unit, 'e) t -> _, Base.unit -> 'at -> _, [> Subtyping.many_getter ]) accessor -> 'at -> (Base.unit, 'e) t
val iter : ((Base.unit -> 'a -> _, Base.unit -> 'at -> _, [> Subtyping.many_getter ]) accessor -> 'at -> f:('a -> (Base.unit, 'e) t) -> (Base.unit, 'e) t) optional_args
val iteri : (('i -> 'a -> _, Base.unit -> 'at -> _, [> Subtyping.many_getter ]) accessor -> 'at -> f:('i Index.t -> 'a -> (Base.unit, 'e) t) -> (Base.unit, 'e) t) optional_args
val sum : ((module Base.Container.Summable with type t = 'sum) -> (Base.unit -> 'a -> _, Base.unit -> 'at -> _, [> Subtyping.many_getter ]) accessor -> 'at -> f:('a -> ('sum, 'e) t) -> ('sum, 'e) t) optional_args
val sumi : ((module Base.Container.Summable with type t = 'sum) -> ('i -> 'a -> _, Base.unit -> 'at -> _, [> Subtyping.many_getter ]) accessor -> 'at -> f:('i Index.t -> 'a -> ('sum, 'e) t) -> ('sum, 'e) t) optional_args
val count : ((Base.unit -> 'a -> _, Base.unit -> 'at -> _, [> Subtyping.many_getter ]) accessor -> 'at -> f:('a -> (Base.bool, 'e) t) -> (Base.int, 'e) t) optional_args
val counti : (('i -> 'a -> _, Base.unit -> 'at -> _, [> Subtyping.many_getter ]) accessor -> 'at -> f:('i Index.t -> 'a -> (Base.bool, 'e) t) -> (Base.int, 'e) t) optional_args
val map_reduce : ((Base.unit -> 'a -> _, Base.unit -> 'at -> _, [> Subtyping.many_getter ]) accessor -> 'at -> empty:'b -> combine:('b -> 'b -> 'b) -> f:('a -> ('b, 'e) t) -> ('b, 'e) t) optional_args
val map_reducei : (('i -> 'a -> _, Base.unit -> 'at -> _, [> Subtyping.many_getter ]) accessor -> 'at -> empty:'b -> combine:('b -> 'b -> 'b) -> f:('i Index.t -> 'a -> ('b, 'e) t) -> ('b, 'e) t) optional_args
val map_reduce_nonempty : ((Base.unit -> 'a -> _, Base.unit -> 'at -> _, [> Subtyping.nonempty_getter ]) accessor -> 'at -> combine:('b -> 'b -> 'b) -> f:('a -> ('b, 'e) t) -> ('b, 'e) t) optional_args
val map_reduce_nonemptyi : (('i -> 'a -> _, Base.unit -> 'at -> _, [> Subtyping.nonempty_getter ]) accessor -> 'at -> combine:('b -> 'b -> 'b) -> f:('i Index.t -> 'a -> ('b, 'e) t) -> ('b, 'e) t) optional_args