package monadlib

  1. Overview
  2. Docs

LazyPlus is another base module useful when the monad is a lazy data structure. We then allow the plus operation to be non-strict in its second argument, which makes it possible to use functions such as Monad.lsum lazily. This is what you want for lazy lists.

include BatInterfaces.Monad
type 'a m

The type of a monad producing values of type 'a.

val bind : 'a m -> ('a -> 'b m) -> 'b m

Monadic binding.

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

val return : 'a -> 'a m

Return a value, that is, put a value in the monad.

val zero : unit -> 'a m
val lplus : 'a m -> 'a m Lazy.t -> '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.