package bap-std

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Monad transformers.

module IO = Monad.T.Inner(Outer) is a monad Inner wrapped into monad Outer. For example, monad module OLwt = Monad.T.Option(Lwt) will allow to work with optional values in the Lwt IO monad, e.g.,

open OLwt
let require p = if p then return (Some ()) else return None
let authenticate user passwd =
  read_credentials >>= fun (u,p) ->
  require (user = u) >>= fun () ->
  require (passwd = p)

Not all monands are transformable into anothers. For example, in general it is not possible to wrap IO monad into other monad (but it is possible to in the opposite direction). State monad here is a special case, although it is very similiar to the IO monad it still can be wrapped into some other monad. However, this wrapping is more like intersection, as the returned monad actually behaves like an intersection of the outer and inner monad.

module Option : sig ... end

Option Monad Transformer

module Or_error : sig ... end

Or_error Monad Transformer

module Result : sig ... end

Result Monad Transformer.

module State : sig ... end

Result Monad Transformer.

OCaml

Innovation. Community. Security.