Back to Language Ext

README

LanguageExt.Core/Traits/Monads/README.md

4.4.41.0 KB
Original Source

Why do we even need monads?

  • Monads encapsulate impure side effects and other effects, making them pure.
  • Monads allow sequencing of operations without resorting to statements.
  • Monads (with LINQ) allow us to write pure code that looks a lot like statements in imperative code.
  • Monads de-clutter your code making it more declarative.

Quite simply: Monads are the 'statements' of pure functional programming and they encapsulate messy boilerplate and side-effects.

For a deeper dive into the 'why?' of monads, then check out Paul Louth's Higher-Kinds series.

  • Monad is the home of the main Monad<M> trait as well as its extension methods and Monad module type.
  • MonadIO has the IO variant of the monad that allows lifting of the IO<A> monad into a monad-transformer stack.
  • MonadT has the MonadT<T, M> monad-transformer trait, it allows the lifting of a monad M into a monad-transformer T.