Homonym: monad (Unit)
A monad is a design pattern used in functional programming to handle values and computations in a consistent way. It allows for the chaining of operations while managing side effects, such as state changes or input/output, without losing the functional programming principles of immutability and purity. Monads encapsulate values and provide a way to apply functions to these values in a controlled manner.
In programming languages like Haskell, monads are represented as types that implement specific operations, such as bind and return. These operations enable the sequencing of computations, making it easier to work with complex data flows. Common examples of monads include the Maybe monad for handling optional values and the IO monad for managing input and output operations.