By calling ‘:set –Wall’ at ghci prompt,
you can enable warnings at GHCi prompt.
Fact.hs
factorial :: Integer -> Integer factorial n | n == 0 = 1 | n /= 0 = n * factorial (n-1)
Load above
program into GHCi prompt.
Prelude> :load Fact.hs [1 of 1] Compiling Main ( Fact.hs, interpreted ) Ok, modules loaded: Main. *Main>
Now enable
warnings using ‘:set –Wall’ command and reload Fact.hs.
*Main> :set -Wall *Main> *Main> :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.
How
to disable warnings?
Use ‘:set –w’ to disable warnings.
*Main> :set -w *Main> *Main> :load Fact.hs [1 of 1] Compiling Main ( Fact.hs, interpreted ) Ok, modules loaded: Main.
No comments:
Post a Comment