Last active
August 29, 2015 14:02
-
-
Save damncabbage/c201d213a828cb54ac6b to your computer and use it in GitHub Desktop.
GHC compiler warnings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sumDigits :: [Int] -> Int | |
sumDigits (x:xs) = x + sumDigits xs | |
-- Missing the "sumDigits [] = 0" base case. | |
main = do | |
putStr $ show $ sumDigits [1,2,3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Without options: | |
$ ghc | |
Linking dig ... | |
# With -Wall: | |
$ ghc dig.hs -Wall | |
[1 of 1] Compiling Main ( dig.hs, dig.o ) | |
dig.hs:4:1: Warning: | |
Top-level binding with no type signature: main :: IO () | |
dig.hs:2:1: Warning: | |
Pattern match(es) are non-exhaustive | |
In an equation for ‘sumDigits’: Patterns not matched: [] | |
Linking dig ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment