module Main where import IO main = do hSetBuffering stdin LineBuffering nums <- getNumbers putStrLn ("The sum is " ++ (filtr (+) 0 nums)) putStrLn ("The product is " ++ (filtr (*) 1 nums)) printFactorials nums factorial 0 = 1 factorial 1 = 1 factorial 2 = 2 factorial n = n * factorial (n-1) printFactorials (x:xs) = putStrLn (x ++ " factorial is " ++ (factorial x)) printFactorials xs getNumbers = do putStrLn "Give me a number (or 0 to stop):" my_line <- getLine let my_nbr = read my_line -- Test.hs:27:1: Parse error in pattern if my_line == 0 then return [] else rest <- getNumbers return (my_nbr : rest)