Catamorphism and tree-traversing in Haskell

后端 未结 2 1441
萌比男神i
萌比男神i 2020-12-13 15:52

I am impatient, looking forward to understanding catamorphism related to this SO question :)

I have only practiced the beginning of Real World Haskell tutorial. So,

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-13 16:17

    I think you were were asking a question about the {}'s. There is an earlier question with a good discussion of {}'s. Those are called Haskell's record syntax. The other question is why construct the algebra. This is a typical function paradigm where you generalize data as functions.

    The most famous example is Church's construction of the Naturals, where f = + 1 and z = 0, 0 = z, 1 = f z, 2 = f (f z), 3 = f (f (f z)), etc...

    What you are seeing is essentially the same idea being applied to a tree. Work the church example and the tree will click.

提交回复
热议问题