Saturday, June 13, 2015

An awfully simple definition of a monad

Here's a definition of a monad from wikipidea which seems pretty simple

Formally, a monad consists of a type constructor M and two operations, bind and return (where return is often also called unit). The operations must fulfill several properties to allow the correct composition of monadic functions (i.e. functions that use values from the monad as their arguments or return value). The return operation takes a value from a plain type and puts it into a monadic container using the constructor, creating a monadic value. The bind operation performs the reverse process, extracting the original value from the container and passing it to the associated next function in the pipeline, possibly with additional checks and transformations.

That is, a monad is a type which is used by some functions (that accept monads) to combine them into a chain.

No comments :

Post a Comment