Skip to content

Instantly share code, notes, and snippets.

@damncabbage
Last active August 29, 2015 14:02
Show Gist options
  • Save damncabbage/c201d213a828cb54ac6b to your computer and use it in GitHub Desktop.
Save damncabbage/c201d213a828cb54ac6b to your computer and use it in GitHub Desktop.
GHC compiler warnings
sumDigits :: [Int] -> Int
sumDigits (x:xs) = x + sumDigits xs
-- Missing the "sumDigits [] = 0" base case.
main = do
putStr $ show $ sumDigits [1,2,3]
# 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