Skip to content

kanitsharma/pokemonads

Repository files navigation

Pokemonads

Fantasy Land

Pokemonads is a collection of common algebraic data types and combinators which are compatible with Fantasy Land

Fistful of monads and more ✊

“Once you understand monads, you immediately become incapable of explaining them to anyone else” Lady Monadgreen’s curse ~ Gilad Bracha (used famously by Douglas Crockford)

A monad is a way of composing functions that require context in addition to the return value, such as computation, branching, or I/O. Monads type lift, flatten and map so that the types line up for lifting functions a => M(b), making them composable. It's a mapping from some type a to some type b along with some computational context, hidden in the implementation details of lift, flatten, and map:

  • Functions map: a => b
  • Functors map with context: Functor(a) => Functor(b)
  • Monads flatten and map with context: Monad(Monad(a)) => Monad(b)

Why do we need monads? here is a great explanation

Installation

ADTs -> Contains all basic monads

  npm i -s @pokemonads/adts
  // or
  yarn add @pokemonads/adts

Combinators -> A collection of basic combinators and utilities

  npm i -s @pokemonads/combinators
  // or
  yarn add @pokemonads/combinators