Monads: Are they worth it?
Monads are interfaces for sequencing behaviors related to a data type. Monads are similar to Unix pipes. They transform input and return the same output type. While pipes describe the function, Monads describe the data type flowing through pipes. Let’s look at pseudocode defining a monad: // Java: one of the best languages for defining interfaces... interface Monad<M, T> { // Return is a class method: static isn't legal java static Monad<M, T> Return(value T) Monad<M, U> Bind<U>(f Function<T, U>) // f = func(T) -> U } We define the Monad as a generic interface. M is the data type implementing the monad interface and T is the input type for pipeline functions. M is the output value and T is the input type. In the simplest case, both can be the same type, like Text in Unix pipes. ...