This is what I have, I want an output like this
*Main> sumThree
Please enter three integers:
1
2
3
Their sum is: 6
(1,2,3)
I however keep getting , without the summ
*Main> sumThree
Please enter three integers:
1
2
3
Their sum is:
(1,2,3)
**summ :: Integer -> Integer -> Integer -> IO Integer
summ x1 x2 x3 = return(x1+x2+x3)
sumThree :: IO (Integer, Integer, Integer)
sumThree = do putStr "Please enter tree integers:"
x1 <- getInteger
x2 <- getInteger
x3 <- getInteger
putStr "Their Sum is: "
summ x1 x2 x3
return(x1,x2,x3)**
You have to actually print the result of
summ.Don’t
returnin yoursummfunction, so that the function’s result type isIntegeras opposed toIO Integer. Then, doinstead of just
summ x1 x2 x3.Also, you do know about the
sumbuilt-in (Prelude) function right? It takes an array ofNum‘s, so you can just doputStr (show (sum [x1, x2, x3])).