- Value, object.
- Data constructor, a box or a ghost box.
- Type constructor, a set of boxes.
- Type classes, classes of people who have a certain set of skills.
Clarification of ghost boxes:
They look like boxes, but actually you can directly touch the object inside them.
That is, the box is an illusion.
Example set of boxes MAYBE
:
- box
Just
- box
Nothing
Each class of people is trained to handle a box in a certain way.
Let's take a look at the people class FUNCTORS
, skill set:
- skill
fmap
, description: execute an action on a box
For example, when a functor performs an fmap
on a Just
box,
he first opens the box, then executes the action on the item in the box,
then takes a new box of the same type and puts the item in the new box.
And when he performs an fmap
on a Nothing
box,
he just takes a new Nothing
box, nothing more.
Let's look at another class of people, called MONADS
,
these people have been mentored by the functors,
so they possess the same basic skillset:
- skill
>>=
, description: take a box and a box-producing machine,
and do something with those things
When a monad receives a Just
box, he knows that he first has to open the box,
get the item out of it and then put it in the machine.
Like the functor, when a monad receives a Nothing
box,
he just takes a new Nothing
box.