package alba

  1. Overview
  2. Docs
Alba compiler

Install

Dune Dependency

Authors

Maintainers

Sources

0.4.2.tar.gz
sha256=203ee151ce793a977b2d3e66f8b3a0cd7a82cc7f15550c63d88cb30c71eb5f95
md5=64367c393f80ca784f88d07155da4fb0

doc/alba.fmlib/Fmlib/List/Monadic_fold/index.html

Module List.Monadic_fold

Monadic list folding

Parameters

Signature

val fold_left : ('a -> 'b -> 'b M.t) -> 'a t -> 'b -> 'b M.t

fold_left f lst start leftfolds the function f over the list lst starting with the value start. Continuation of the fold is determined by the bind operator >>= of the monad M. E.g. if the monad M is Option the folding stops as soon as f e acc returns the value None.

     fold_left f [a b c ...] s =
       M.(f a s   >>= fun acc ->
          f b acc >>= fun acc ->
          f c acc >>= fun acc ->
          ...)
val fold_right : ('a -> 'b -> 'b M.t) -> 'a t -> 'b -> 'b M.t

The same as fold_left just right folding.

     fold_right f [... x y z] s =
     fold_left f (rev [... x y z]) s =
       M.(f z s   >>= fun acc ->
          f y acc >>= fun acc ->
          f x acc >>= fun acc ->
          ...)
val foldi_left : (int -> 'a -> 'b -> 'b M.t) -> 'a t -> 'b -> 'b M.t

The same as fold_left except that the folding function receives the position of the first argument in the list as an additional argument.

OCaml

Innovation. Community. Security.