diff --git a/src/libraries/monads/monad.mli b/src/libraries/monads/monad.mli index a31294b6e49cdab9f3ac85c4ad58a418bc8f3eb9..a871fa73436e46681f64a91cd575b06b43d62e0f 100644 --- a/src/libraries/monads/monad.mli +++ b/src/libraries/monads/monad.mli @@ -20,6 +20,8 @@ (* *) (**************************************************************************) +(** This module provides a generic monad interface based on Keisli and Categoric + defintion of monads. *) (** {2 Kleisli triple signature for a monadic type constructor ['a t]} @@ -115,7 +117,9 @@ end nested applications of the monad. It must also satisfy some laws : 2. ∀m:('a t t t), [map flatten (flatten m) ≣ flatten (flatten m)] + 3. ∀m:('a t), [flatten (map return m) ≣ flatten (return m) ≣ m] + 4. ∀m:('a t t), ∀f: ('a -> 'b), [flatten (map (map f) m) ≣ map f (flatten m)] As there is no way in the OCaml type system to enforce those properties, @@ -162,7 +166,9 @@ end using the operations required by the others. Indeed : 1. ∀m:('a t), ∀f:('a -> 'b), [map f m ≣ bind (fun x -> return (f x)) m] + 2. ∀m:('a t t), [flatten m ≣ bind identity m] + 3. ∀m:('a t), ∀f:('a -> 'b t), [bind f m ≣ flatten (map f m)] All required laws expressed in both minimal signatures are respected diff --git a/src/libraries/monads/result.mli b/src/libraries/monads/result.mli index 0411390df5fcbf37e1d0977f3a46697c7547bc12..7e8edc10e98b0cf18c6d7b04d08db93baa33c030 100644 --- a/src/libraries/monads/result.mli +++ b/src/libraries/monads/result.mli @@ -20,8 +20,11 @@ (* *) (**************************************************************************) -(* Adding let binding operators to the Result module. See - https://v2.ocaml.org/manual/bindingops.html for more information. *) +(** Adding let binding operators to the Result module. + @see <https://v2.ocaml.org/manual/bindingops.html> + This module does not use the generic monad interface (cf. {!Monad}) because + of the error type, which would require another layer of functors. +*) include module type of Stdlib.Result