jksevend
jksevend

Reputation: 458

Haskell ghci Variable not in scope

Hello im using sublime text 3 and my cmd shell with ghci. I wrote following function in st3:

testing :: Int -> Bool
testing 0 = True
testing 1 = False
testing n = testing(n mod 2)

I know haskell provides an even function but we have to write our own even function so i came up with this. When im loading the file into the ghci:

:cd <pathtofile>
:l myfile.hs

and try to execute my function with

testing 10

i get this error:

 Variable not in scope: testing :: t0 -> t

I should probably mention that testing :: Int -> Bool shares the file with a fibonacci function but that shouldnt be the problem right? Any help appreciated!

Upvotes: 1

Views: 1368

Answers (1)

Alejandro Alcalde
Alejandro Alcalde

Reputation: 6220

n mod 2 is wrong syntax, you have two possibilities here:

  • mod n 2
  • n `mod` 2

Upvotes: 5

Related Questions