package containers

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

The free monad is built by nesting applications of a functor F.

For instance, Lisp-like nested lists can be built and dealt with like this:

module Lisp = CCCat.FreeMonad(CCList);;

let l = Lisp.(inj [1;2;3]  >>= fun x -> inj [x; x*2; x+100]);;
module F : FUNCTOR
type +'a t =
  1. | Return of 'a
  2. | Roll of 'a t F.t
include MONAD with type 'a t := 'a t
include MONAD_BARE with type 'a t := 'a t
val return : 'a -> 'a t
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
include APPLICATIVE with type 'a t := 'a t
include FUNCTOR with type 'a t := 'a t
val map : ('a -> 'b) -> 'a t -> 'b t
val pure : 'a -> 'a t
val (<*>) : ('a -> 'b) t -> 'a t -> 'b t
val inj : 'a F.t -> 'a t
OCaml

Innovation. Community. Security.