
10 Feb
2015
10 Feb
'15
8:18 a.m.
On Tue, Feb 10, 2015 at 6:58 AM, Joel Neely
{-# OPTIONS_GHC -Wall #-}
sumDigits :: [Integer] -> Integer sumDigits [] = 0 sumDigits (n:ns) | n < 10 = n + sumDigits ns | n >= 10 = r + sumDigits (q : ns) where (q, r) = n `quotRem` 10
sumList :: [Integer] -> Integer sumList [] = 0 sumList (n:ns) = n + sumList ns
ghc can't decide whether or not the tests in the guards are complete or not. If you rewrite the second condition as "otherwise", it'll recognize the catch-all and you won't get a warning.