DEV Community

Pankaj Sharma
Pankaj Sharma

Posted on • Edited on

1

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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

DEV is better (more customized, reading settings like dark mode etc) when you're signed in!

Okay