I am teaching myself Haskell
I want to write a function that recursively finds the first number that has an integer square root and is smaller than a starting number.
It looks like this:
findFirstSquare :: Int -> Int
findFirstSquare x
| x <= 0 = error "This function only works for 1 or above"
| fromInteger(floor(sqrt(x))) == (sqrt x) = x
| otherwise = intSqrt(x - 1)
But the GHC parser complains about the middle guard when parsing my .hs file, with the following: No instance for (RealFrac Int) arising from a use of `floor' at ...
However, if I type the following into the interactive window, it happily parses it:
fromInteger(floor(sqrt(4))) == (sqrt 4)
My question is: Why am I getting a parser error for an expression which seems equivalent to one that is parsed correctly from the command line?