昨天的Wikibender以Comonads上的stackoverflow问题开始,最终出现在MarkCC关于Finger Trees 的文章中.
在文章中,他广泛使用了Reduce类型类.他写了关于这个类型类的文章,好像它是一个非常常见且经常使用的库,但我无法在hackage上找到它,也无法找到足够的文档来真正理解代码.
有人可以帮助我理解Reduce类型类正在做什么,(-<)和(>-)运算符如何工作,以及应该告诉我文章中的代码(下面复制)?
清单1:Node的实例声明
instance Reduce Node where
reducer (-<) (Node2 a b) z = a -< (b -< z)
reducer (-<) (Node3 a b c) z = a -< (b -< (c -< z))
reducer (>-) (Node2 b a) = (z >- b) >- a
reducer (>-) (Node3 c b a) = ((z >- …Run Code Online (Sandbox Code Playgroud)