コンテンツにスキップ

Monad: Another Bridge

The Kleisli arrow at our disposal - a function that produces its output within a container:

image

Now, let’s look back at the mapper function we created using Functor:

image

These two concepts suggest an intriguing possibility: what if we could create a function that transforms a Kleisli arrow into a container mapper function? Such a function would serve as another bridge between worlds.

This transforming function is called bind. It takes a Kleisli arrow and produces a container mapper function:

image

This transformation - from Kleisli arrow to container mapper function - is precisely what defines a Monad . Where Functor’s map lifts regular functions to work with containers, bind transforms Kleisli arrows into container mappers.

This provides a completely different way to bridge the world of functions and containers, and this transformative capability is the core essence of what we call a Monad.

image

image

image

image