DEV Community

Pankaj Sharma
Pankaj Sharma

Posted on • Updated on

In a nutshell: Monads and Functors

Functors

Any object that provides a method with following signature is a functor

map :: (a -> b) -> m a -> m b

m is a container, map opens up the container and converts type a to b.

Monads

Any object that provides a method with following signature is a monad

(flatMap) :: m a -> (a -> m b) -> m b

m is a container, flatMap opens up the container converts a to mb and if in the process multiple mb's are created then it flattens them to return a single mb.

Top comments (0)