package mnd
A small monads library
Install
Dune Dependency
Authors
Maintainers
Sources
1.1.0.tar.gz
md5=af10f06c9efd223431f8c4a42aeb80c7
sha512=5033d59e56877d85ec7225101d2d8c5cba9fa056225cffab26c8e3d2ae50e4fc8fba679397a5e620caff4174cbaeae14163ddc9e7abab36a018f1f04fa0dd30c
doc/index.html
Mnd 1.1.0
A small library for programming with monads. It aims to be comprehensible instead of comprehensive Everything is standard and already exists in various places, this is simply a selection for easy re-use:
- An interface to define monads with one or two type parameters
- A small selection of monadic functions such as
(>>=)
ormapM
- Support for
let*
andlet+
syntax - A few standard instances of monads
The details can be found in the documentation. Feedback is welcome on the GitHub repository.
Functions
The individual functions are documented in the MONAD
interface.
Syntax
OCaml 4.08.0 added support for user-defined binding operators to facilitate working with monads and similar structures. Monads defined with this library automatically have access to the let*
and let+
syntax.
Instances
Option
: Canonical instance of'a option
. Also known asMaybe
.Result
: Canonical instance of('a,'b) result
. Also known asError
orEither
. Providesand*
andand+
with the semantics that if either compuation fails, the combined product computation also fails. If both arguments of a product fail then the result is the error of the first one.Reader
: Also known asEnv
,Environment
or configuration monad.Writer
: Also known as logger monad.State