相关疑难解决方法(0)

开始Haskell - 得到"不在范围内:数据构造函数"错误

我正在查看Haskell O'Reilly书中的问题.我正在处理的问题是

Using the binary tree type that we defined earlier in this chapter, 
write a function that will determine the height of the tree. The height 
is the largest number of hops from the root to an Empty. For example, the 
tree Empty has height zero; Node "x" Empty Empty has height one; 
Node "x" Empty (Node "y" Empty Empty) has height two; and so on.
Run Code Online (Sandbox Code Playgroud)

我正在将我的代码写在一个名为ch3.hs的文件中.这是我的代码:

36 data Tree a = Node a (Tree a) (Tree a)
37 …
Run Code Online (Sandbox Code Playgroud)

haskell scope

20
推荐指数
2
解决办法
4万
查看次数

ghci没有从文件加载函数

在test.hs中,我有:

doubleMe x = x + x
Run Code Online (Sandbox Code Playgroud)

在ghci中,我键入:

Prelude> :l test
[1 of 1] Compiling Main             ( test.hs, interpreted )
Ok, modules loaded: Main.
*Main> doubleMe 9

<interactive>:1:0: Not in scope: `doubleMe'
*Main> 
Run Code Online (Sandbox Code Playgroud)

为什么?怎么修?

haskell ghci

6
推荐指数
3
解决办法
5903
查看次数

标签 统计

haskell ×2

ghci ×1

scope ×1