
5 May
2003
5 May
'03
8:20 p.m.
Hi I'm trying to write a simple program to get user input and execute a function based on the input. The program follows: import IO main = do putStrLn "1) f1" putStrLn "2) f2" choice <- getLine case choice of 1 -> do putStrLn "f1" 2 -> do putStrLn "f2" _ -> do putStrLn "" When compiled with ghc I get the following error: test.hs:8: No instance for (Num String) arising from the pattern `2' at test.hs:8 In a case alternative: 2 -> do putStrLn "f2" In the case expression: case choice of 1 -> do putStrLn "f1" 2 -> do putStrLn "f2" _ -> do putStrLn "" Please can someone explain. Thanks