DEV Community

Dima
Dima

Posted on

Catamorphisms

Some time ago I read about catamorphisms. It's beautiful concept, but it can be difficult to understand it when you read it first time. It looks too abstract and almost unusable in the real life.
But when you understand it, you start seeing it everywhere.
Like, "Well, maybe it's time to replace MapReduce with Catamorphism?"
I'm not going to explain what is cata and ana morphisms. I'm not sure if I would do it better than Bartosz Milewski. So here are the links to great lectures about it:
https://www.youtube.com/watch?v=PAqzQMzsUU8
https://www.youtube.com/watch?v=jpl7FE2TZTE
It's worth to watch both series of lectures.
Also a great article about catamorphisms is here:
https://www.schoolofhaskell.com/user/bartosz/understanding-algebras
I wrote down examples from lectures as accurate as I could.
As I feel it, playing with this code make it easier to understand lectures and to find why and where you need cata.
This code available here:
https://gist.github.com/DKurilo/5e5563f4c2a8e8ca53a7b98ebf59e9f1
You can also play with it on Repl.it
https://repl.it/@DimaKurilo/Catamorphisms

Top comments (0)