11.2 Abstract Data Types

11.2 抽象数据类型

import TreeADT

See TreeADT.lhs

参见 TreeADT.lhs。

Since the constructors for type Tree are hidden, pattern matching cannot be used.

由于类型 Tree 的构造器是隐藏的,所以不能使用模式匹配。

fringe :: Tree a -> [a]
fringe x = if isLeaf x then [cell x]
                       else fringe (left x) ++ fringe (right x)
e1 :: [Int]
e1 = fringe (branch (branch (leaf 3) (leaf 2)) (leaf 1))

11.3 More Features

11.3 更多特性

No examples (yet).

没有例子(暂时)。