Section 11

第 11 节

Since each of these files is a separate module we need to place Tree in it's own module. See Tree.lhs

由于这些文件每一个都是独立的模块,我们需要把 Tree 放到它自己的模块里。

参见 Tree.lhs。

import Tree ( Tree(Leaf, Branch), fringe)
e1 :: [Int]
e1 = fringe (Branch (Leaf 1) (Leaf 2))

You could also just import Tree and get everything from Tree without explicitly naming the entities you need.

你也可以只写 import Tree,从而获得 Tree 中的所有内容,而不必显式

指出需要的实体。

This interactive Haskell environment can evaluate expressions in any module. You can do :m Tree to get to that module for interactive evaluation.

这个交互式 Haskell 环境可以在任何模块中求值表达式。你可以输入

:m Tree 切换到那个模块进行交互式求值。