ghci不从文件加载函数 [英] ghci not loading function from file

查看:93
本文介绍了ghci不从文件加载函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在test.hs中,我有:

  doubleMe x = x + x 

在ghci中,我输入:

 前奏> :l测试
[1的1]编译主(test.hs,解释)
好​​了,加载的模块:Main。
* Main> doubleMe 9

< interactive>:1:0:不在范围内:`doubleMe'
* Main>

为什么?如何解决?

解决方案

您确定您正在加载正确的test.hs吗?也许你在错误的目录中。或者,也许你在添加doubleMe的定义后没有保存test.hs。


In test.hs, I have:

doubleMe x = x + x

In ghci, I type:

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> 

Why? How to fix?

解决方案

Are you sure that you're loading the right test.hs? Maybe you're in the wrong directory. Or maybe you didn't save test.hs after adding the definition of doubleMe.

这篇关于ghci不从文件加载函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆