Ah, sorry, I didn't think of that when I responded to your other
thread. You can always insert a check before recursion:
toDigits :: Integer -> [Integer]
toDigits n
| n < 0 = []
| otherwise = (if n' > 0 then toDigits n' else []) ++ [n `mod` 10]
where n' = n `div` 10
Regards,
Marcin Mrotek