package jhupllib

  1. Overview
  2. Docs
type 'a m
include Monad.MonadPlus with type 'a m := 'a m
include Monad.BasePlus with type 'a m := 'a m
include BatInterfaces.Monad with type 'a m := 'a m
val zero : unit -> 'a m
val plus : 'a m -> 'a m -> 'a m
val null : 'a m -> bool

null x implies that x is zero. If you do not want to or cannot answer whether a given x is zero, then null x should be false. I have provided this so that streams can be implemented more efficiently.

include Monad.Monad with type 'a m := 'a m
include BatInterfaces.Monad with type 'a m := 'a m
val bind : 'a m -> ('a -> 'b m) -> 'b m

Monadic binding.

bind m f executes first m then f, using the result of m.

include Applicative.Applicative with type 'a m := 'a m
include Applicative.Base with type 'a m := 'a m
val return : 'a -> 'a m
val (<*>) : ('a -> 'b) m -> 'a m -> 'b m
val lift1 : ('a -> 'b) -> 'a m -> 'b m
val lift2 : ('a -> 'b -> 'c) -> 'a m -> 'b m -> 'c m
val lift3 : ('a -> 'b -> 'c -> 'd) -> 'a m -> 'b m -> 'c m -> 'd m
val lift4 : ('a -> 'b -> 'c -> 'd -> 'e) -> 'a m -> 'b m -> 'c m -> 'd m -> 'e m
val (<$>) : ('a -> 'b) -> 'a m -> 'b m

Alias for lift1.

val map_a : ('a -> 'b m) -> 'a list -> 'b list m
val (<*) : 'a m -> 'b m -> 'a m
val (>*) : 'a m -> 'b m -> 'b m
val (>>=) : 'a m -> ('a -> 'b m) -> 'b m
val join : 'a m m -> 'a m
val filter_m : ('a -> bool m) -> 'a list -> 'a list m
val onlyif : bool -> unit m -> unit m
val unless : bool -> unit m -> unit m
val ignore : 'a m -> unit m
val filter : ('a -> bool) -> 'a m -> 'a m
val of_list : 'a list -> 'a m
val sum : 'a list m -> 'a m
val msum : 'a m list -> 'a m
val guard : bool -> 'a m -> 'a m
val transpose : 'a list m -> 'a m list

Generalises matrix transposition. This will loop infinitely if BasePlus.null cannot answer true for zeroes.

include Jhupllib_monad_utils.Utils with type 'a m := 'a m
val sequence : 'a m Batteries.Enum.t -> 'a Batteries.Enum.t m
val mapM : ('a -> 'b m) -> 'a Batteries.Enum.t -> 'b Batteries.Enum.t m
val pick_enum : 'a Batteries.Enum.t -> 'a m
val enum : 'a m -> 'a Batteries.Enum.t
val stop_unless : bool -> unit m
val empty : unit -> 'a m
OCaml

Innovation. Community. Security.