Enjoy this piece of work about recursion schemes in Scala: Main Talk
Here there are the code snippets used above: jupyer notebook
Feel free to play with this in Scastie an online scala editor.