<s>
In	O
category	O
theory	O
,	O
the	O
concept	O
of	O
catamorphism	B-Application
(	O
from	O
the	O
Ancient	O
Greek	O
:	O
"	O
downwards	O
"	O
and	O
"	O
form	O
,	O
shape	O
"	O
)	O
denotes	O
the	O
unique	O
homomorphism	O
from	O
an	O
initial	O
algebra	O
into	O
some	O
other	O
algebra	O
.	O
</s>
<s>
In	O
functional	B-Language
programming	I-Language
,	O
catamorphisms	B-Application
provide	O
generalizations	O
of	O
folds	B-Application
of	O
lists	O
to	O
arbitrary	O
algebraic	O
data	O
types	O
,	O
which	O
can	O
be	O
described	O
as	O
initial	O
algebras	O
.	O
</s>
<s>
The	O
dual	O
concept	O
is	O
that	O
of	O
anamorphism	B-Application
that	O
generalize	O
unfolds	B-Application
.	O
</s>
<s>
A	O
hylomorphism	B-Application
is	O
the	O
composition	O
of	O
an	O
anamorphism	B-Application
followed	O
by	O
a	O
catamorphism	B-Application
.	O
</s>
<s>
The	O
open	O
brackets	O
used	O
are	O
known	O
as	O
banana	O
brackets	O
,	O
after	O
which	O
catamorphisms	B-Application
are	O
sometimes	O
referred	O
to	O
as	O
bananas	B-Application
,	O
as	O
mentioned	O
in	O
Erik	O
Meijer	O
et	O
al	O
.	O
</s>
<s>
One	O
of	O
the	O
first	O
publications	O
to	O
introduce	O
the	O
notion	O
of	O
a	O
catamorphism	B-Application
in	O
the	O
context	O
of	O
programming	O
was	O
the	O
paper	O
“	O
Functional	B-Language
Programming	I-Language
with	O
Bananas	B-Application
,	O
Lenses	O
,	O
Envelopes	O
and	O
Barbed	O
Wire	O
”	O
,	O
by	O
Erik	O
Meijer	O
et	O
al.	O
,	O
which	O
was	O
in	O
the	O
context	O
of	O
the	O
Squiggol	B-Application
formalism	O
.	O
</s>
<s>
We	O
give	O
a	O
series	O
of	O
examples	O
,	O
and	O
then	O
a	O
more	O
global	O
approach	O
to	O
catamorphisms	B-Application
,	O
in	O
the	O
Haskell	B-Language
programming	I-Language
language	I-Language
.	O
</s>
<s>
Consider	O
the	O
functor	O
fmaybe	O
mapping	O
a	O
data	O
type	O
b	O
to	O
a	O
data	O
type	O
fmaybe	O
b	O
,	O
which	O
contains	O
a	O
copy	O
of	O
each	O
term	O
from	O
b	O
as	O
well	O
as	O
one	O
additional	O
term	O
Nothing	O
(	O
in	O
Haskell	B-Language
,	O
this	O
is	O
what	O
Maybe	O
does	O
)	O
.	O
</s>
<s>
An	O
f-algebra	B-Application
shall	O
now	O
map	O
Nil	O
to	O
some	O
special	O
term	O
nil	O
of	O
b	O
or	O
"	O
merge	O
"	O
a	O
pair	O
(	O
any	O
other	O
term	O
of	O
the	O
constructed	O
type	O
)	O
into	O
a	O
term	O
of	O
b	O
.	O
</s>
<s>
Deeper	O
category	O
theoretical	O
studies	O
of	O
initial	O
algebras	O
reveal	O
that	O
the	O
F-algebra	B-Application
obtained	O
from	O
applying	O
the	O
functor	O
to	O
its	O
own	O
initial	O
algebra	O
is	O
isomorphic	O
to	O
it	O
.	O
</s>
<s>
The	O
recursively	O
defined	O
catamorphisms	B-Application
can	O
now	O
be	O
coded	O
in	O
single	O
line	O
,	O
where	O
the	O
case	O
analysis	O
(	O
like	O
in	O
the	O
different	O
examples	O
above	O
)	O
is	O
encapsulated	O
by	O
the	O
fmap	O
.	O
</s>
<s>
Since	O
the	O
domain	O
of	O
the	O
latter	O
are	O
objects	O
in	O
the	O
image	O
of	O
f	O
,	O
the	O
evaluation	O
of	O
the	O
catamorphisms	B-Application
jumps	O
back	O
and	O
forth	O
between	O
a	O
and	O
f	O
a	O
.	O
</s>
