A monad in programming is a composable computation description. Monads are an important construct in functional programming languages like Haskell.
A monad in programming is a composable computation description. Monads are an important construct in functional languages like Haskell.
In Haskell, a Monad is simply any type m
with two functions following several algebraic laws:
return :: a -> m a
(>>=) :: m a -> (a -> m b) -> m b
These types can be used for a wide variety of different tasks including: IO, continuations, coroutines, non-determinism, error-handling, mutable state and even parsing. In addition, they are particularly useful for embedding simple DSLs within a functional language like Haskell.