Search code examples
haskelltemplate-haskell

Syntax error on 'mod' Haskell


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


Solution

  • 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.