Syntax error on 'mod' Haskell [closed]

荒凉一梦 提交于 2019-12-23 12:28:59

问题


I am following a haskell tutorial: http://www.seas.upenn.edu/~cis194/lectures/01-intro.html

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

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.

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/)


回答1:


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.



来源:https://stackoverflow.com/questions/24543686/syntax-error-on-mod-haskell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!