4

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

4
  • ideone.com is happy with this: ideone.com/pe3g9C Commented Jul 3, 2014 at 1:51
  • Typically that happens when mod is written as a top-level form. Is the definition of hailstone the only thing in the file? Commented Jul 3, 2014 at 1:52
  • 6
    Are you by any chance typing " ' " ('mod') as opposed to " ` " (`mod `) ? The latter is correct while the former is not; the backtick is not the same as the single quote. Commented Jul 3, 2014 at 1:54
  • @user2407038 well... this is embarrassing... Commented Jul 3, 2014 at 2:52

1 Answer 1

8

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.

Sign up to request clarification or add additional context in comments.

1 Comment

@David Nono, this is the answer to this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.