O'Reilly logo

Functional PHP by Gilles Crettenand

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Monads

We started learning about functors, which are a collection of values that can be mapped over. We then introduced the idea of applicative functors, which allow us to put those values in a certain context and apply functions to them while preserving the context. We also made a quick detour to talk about monoids and their properties.

With all this prior knowledge, we are finally ready to start with the idea of monads. As James Iry humorously noted in A Brief, Incomplete, and Mostly Wrong History of Programming Languages:

A monad is a monoid in the category of endofunctors, what's the problem?

This fictional quote, attributed to Philip Wadler, one of the original people involved in the Haskell specification and a proponent of the use of monads, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required