'mod'Haskell上的语法错误 [英] Syntax error on 'mod' Haskell
问题描述
我正在关注一个haskell教程: http:// www。 seas.upenn.edu/~cis194/lectures/01-intro.html
I am following a haskell tutorial: http://www.seas.upenn.edu/~cis194/lectures/01-intro.html
我正在测试ghci中的函数,我得到了这个部分:
I am testing functions in ghci, i got to this part:
hailstone :: Integer -> Integer
hailstone n
| n `mod` 2 == 0 = n `div` 2
| otherwise = 3*n + 1
我在.hs文件中有这个功能,我启动了ghci在同一个目录中,并执行:l hailstone.hs
I have that function in a .hs file, i fire up ghci in the same directory and go :l hailstone.hs
输出是
the output is
Syntax error on 'mod'
Perhaps you intended to use TemplateHaskell
In the Template Haskell quotation 'mod'
Failed, modules loaded: none.
做了一些Google搜索,试图加载这个'templatehaskell',结果出现了一组不同的错误( http://brandon.si/code/working-with-template -haskell-in-ghci / )
did some googling and tried to load this 'templatehaskell' and just ended up with a different set of errors (http://brandon.si/code/working-with-template-haskell-in-ghci/)
推荐答案
user2407038 正确地建议在评论中,问题是我使用撇号('
)而不是反引号(`
),反引号与我应该使用的单引号不一样。
As user2407038 correctly suggested in the comments, the problem was that I was using apostrophes ('
) as opposed to backticks (`
), the backtick is not the same as the single quote which I should have been using.
这篇关于'mod'Haskell上的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!