I'm just learning Haskell, and I decided to try writing my own version of pred, which returns the number preceding its parameter. I'm using WinGHCi and loading a file called test.hs. Here is my code:
prev :: (Num a) => a -> a
prev x = prev' 0 x
where prev' y z
| (succ y) == z = y
| otherwise = prev' (succ y) z
I get the error:
test.hs:4:5:
parse error (possibly incorrect indentation or mismatched brackets)
How does one properly write a helper function with guards?