|
|
|
|
|
by Periodic
5861 days ago
|
|
It needs to be fixed up a bit. You can somewhat resolve this issue by compiling with -Wall, at which point it will warn you that your pattern matching is non-exhaustive. import System.IO
divide :: Int -> Int -> Maybe Int
divide x 0 = Nothing
divide x y = Just $ x `div` y
printResult :: Maybe Int -> IO ()
printResult (Just x) = print x
main = do
putStr "Type a number: "
hFlush stdout
x <- readLn
printResult $ divide 42 x
|
|