Haskell - 输入`|'解析错误 [英] Haskell - parse error on input `|'

查看:216
本文介绍了Haskell - 输入`|'解析错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  pow1 b e 
| (e == 0)= 1
|否则= b * pow1 b(e-1)

我在.hs文件和加载时,我总是得到相同的分析错误。我不认为它实际上包含任何错误 - 所以我目前的想法是,|签名不是haskell想要的,但它是我Macbook键盘上的标准版本(使用Mac OS)。是否有可能,如果有的话,我该如何解决它?我现在正在使用TextEdit编写代码,并设置纯文本。

Haskell有很大的空白。

  pow1 b e 
| (e == 0)= 1
|否则= b * pow1 b(e-1)


pow1 b e  
| (e == 0)  = 1  
| otherwise = b * pow1 b (e-1)

I have exactly that code in a .hs file and when loading I always get the same parse error. I don't think it actually contains any mistakes - so my current thought is that the "|" sign isn't the one haskell wants, but it's the standard one on my Macbook Keyboard (using Mac OS). Is it possible, and if so how do I go around it? I'm currently using TextEdit to write the code, with the plain text setting on.

解决方案

Be sure to indent the guards; Haskell has significant whitespace.

pow1 b e
    | (e == 0)  = 1
    | otherwise = b * pow1 b (e-1)

这篇关于Haskell - 输入`|'解析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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