输入`='的Haskell错误解析错误 [英] Haskell error parse error on input `='
本文介绍了输入`='的Haskell错误解析错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 Haskell 的新手,在启动 ghci
后,我尝试了:
I'm new to Haskell and after starting ghci
I tried:
f x = 2 * x
我得到了:
<interactive>:1:4: parse error on input `='
我不明白.
奇怪的是,它以前运行良好.我想我已经完成了错误配置的 Haskell.重新安装 ghc6 并不能解决问题.
Strangely, it worked well before. I suppose that I have done misconfigured Haskell. Reinstalling ghc6 doesn't solve the problem.
有关信息,我使用的是 Ubuntu 10.4,而 ghc6 的版本是 6.12.1-12
For information, I use Ubuntu 10.4 and the version of ghc6 is 6.12.1-12
推荐答案
在 GHCi 7.x 或更低版本中,您需要一个 let
来定义其中的内容.
In GHCi 7.x or below, you need a let
to define things in it.
Prelude> let f x = x * 2
Prelude> f 4
8
从 GHC 8.0.1 开始,支持顶级绑定GHCi,因此 OP 的代码无需更改即可运行.
Starting from GHC 8.0.1, top-level bindings are supported in GHCi, so OP's code will work without change.
GHCi, version 8.0.1.20161213: http://www.haskell.org/ghc/ :? for help
Prelude> f x = x * 2
Prelude> f 4
8
这篇关于输入`='的Haskell错误解析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文