The following is my factorial function:
factorial :: Integer -> Integer
factorial n
| n < 0 = -1
| n > 0 = n * factorial (n-1)
| n == 0 = 1
I guess, I covered all the cases (+ve, -ve, 0). When I try to load above code, I am getting following warnings. Why am I getting warnings?
Prelude> :load Fact.hs
[1 of 1] Compiling Main ( Fact.hs, interpreted )
Fact.hs:2:1: Warning:
Pattern match(es) are non-exhaustive
In an equation for ‘factorial’: Patterns not matched: _
Ok, modules loaded: Main.