我正在关注 haskell 教程:http://www.seas.upenn.edu/~cis194/lectures/01-intro.html http://www.seas.upenn.edu/~cis194/lectures/01-intro.html
我正在 ghci 中测试功能,我到达了这部分:
hailstone :: Integer -> Integer
hailstone n
| n `mod` 2 == 0 = n `div` 2
| otherwise = 3*n + 1
我在 .hs 文件中有这个函数,我在同一目录中启动 ghci 并执行 :l hailstone.hs
输出是
Syntax error on 'mod'
Perhaps you intended to use TemplateHaskell
In the Template Haskell quotation 'mod'
Failed, modules loaded: none.
做了一些谷歌搜索并尝试加载这个“templatehaskell”,但最终出现了一组不同的错误(http://brandon.si/code/working-with-template-haskell-in-ghci/ http://brandon.si/code/working-with-template-haskell-in-ghci/)
As 用户2407038 https://stackoverflow.com/users/2407038/user2407038评论中正确建议,问题是我使用了撇号('
) 与反引号 (`
),反引号与我应该使用的单引号不同。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)