I Started writing Haskell code . I tried to write a fibonacci function using Guards -
fibo :: (Num z, Ord z) => z -> z
fibo d
| d <= 0 = 0
| d == 1 = 1
| otherwise = fibo (d-1) + fibo (d-2)
I got this error :-
Illegal type signature: ‘(Num z, Ord z) => z -> z fibo d’ Perhaps you intended to use ScopedTypeVariables In a pattern type-signature
However another function - replicate i have written in a similar way which compiled and worked fine . I can write fibonacci in another way , but I want to know what the error was
fibo
definition? Why is it indented? – Cirdec-fwarn-tabs
. In more recent GHC, pay attention to this warning, which is now enabled by default. And don't use tabs. – dfeuerScopedTypeVariables
anyway, and learn to use it. It's a very helpful and friendly extension. – dfeuer