Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax error on 'mod' Haskell [closed]

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

like image 753
leshow Avatar asked Feb 13 '23 14:02

leshow


1 Answers

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.

like image 128
leshow Avatar answered Feb 24 '23 11:02

leshow