Hi, I just started learning Haskell. But I have been having a problem with defining functions. For example,
diff :: Float-> Float
diff = if x>= y then x-y else y-x
<interactive>:1:29: parse error on input `='
It is rather weird as I have checked quite a few websites and this was supposed to work.
The same occurs when I try for guarded rules, except that it is now for |.
diff :: Float -> Float -> Float
diff x y | x >= y = x - y
| otherwise = y - x
<interactive>:1:42: parse error on input `|'
Please do help!
Thanks a lot.