I was actually able to compile both of these snippets in ghci (version 7.4.2). Something to look out for is using tabs instead of spaces (which could have been lost upon pasting into SO and formatting).
The messages appearing in your second snippet are just compiler warnings. You could clean up your code a little by using the built in pattern matching instead of a case
. Here is an equivalent function:
divide :: Maybe Integer -> Maybe Integer -> Maybe Integer
divide (Just x) (Just y)
| y == 0 = Nothing
| otherwise = Just (div x y)
divide _ _ = Nothing