Module Monads.FilterMonad

FilterMonad

A module providing monadic operations for a custom filter_wrapper type.

type 'a filter_wrapper = 'a

A type alias representing a wrapper for values.

val return : 'a -> 'a filter_wrapper

return x wraps a value x into a filter_wrapper.

val get : 'a filter_wrapper -> 'a

get fw extracts the value from the filter_wrapper.

val bind : 'a filter_wrapper -> bool -> ('a -> 'a filter_wrapper) -> 'a filter_wrapper

bind fw cond f applies the function f to the value inside fw if cond is true, otherwise returns the original fw.

val (>>=) : 'a filter_wrapper filter_wrapper -> (bool * ('a -> 'a filter_wrapper)) -> 'a filter_wrapper filter_wrapper

Infix operator for bind. Equivalent to bind fw cond f.

val (>>|) : 'a -> ('a -> 'b) -> 'b

x >>| f applies the function f to the value x.

val (>>!) : 'a -> 'b -> 'a

x >>! y returns x, ignoring y.

val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a

fold_left f acc lst folds over the list lst using the function f and an accumulator acc.

val map : ('a -> 'b) -> 'a list -> 'b list

map f lst applies the function f to each element of the list lst.

val filter_map : ('a -> 'b option) -> 'a list -> 'b list

filter_map f lst applies the function f to each element of the list lst, where f returns an option. Only the Some values are included in the result.

val iter : ('a -> unit) -> 'a list -> unit

iter f lst applies the function f to each element of the list lst.