>>22
But it is. An endofunctor is nothing more than saying:
We have an operation
fmap : (a -> b) -> f a -> f b
Which should behave as follow:
fmap f . fmap g = fmap (f . g) -- I can fuse computations
fmap id = id -- And I don't change the container
It is endo, because it doesn't send it's objects to another category. It is a functor, because it preserves structure.
A well known functor is an array:
map : (a -> b) -> [a] -> [b]
Which in perl is:
sub map {
my $f = shift;
my $xs = shift;
my $ys = [];
for my $x(@$xs){
$ys[] = $f->(x);
}
return $ys;
}
Everything which follow these laws is a functor. For the monad we have a couple of extra laws. But again, everything which follow those laws is a monad. It is like a design pattern, but than more defined and thus easier to find and apply.
It is not hard, you only need to forget about all those stupid monad tutorials and grab a book about category theory:
www.maths.ed.ac.uk/~aar/papers/maclanecat.pdf