如何打印两个数字之和的结果?打印两个数字的和Haskell
main:: IO()
main = do putStrLn "Insert the first value: "
one <- getLine
putStrLn "Insert the second value: "
two <- getLine
putStrLn "The result is:"
print (one+two)
这给了我一个错误:
ERROR file:.\IO.hs:3 - Type error in application
*** Expression : putStrLn "The result is:" print (one + two)
*** Term : putStrLn
*** Type : String -> IO()
*** Does not match : a -> b -> c -> d
不要用拥抱修改代码这种方式。 –
更有建设性地使用GHC。如果您更喜欢使用解释器而不是编译器,则可以使用GHC附带的'runghc'程序。 – dave4420
@CatPlusPlus拥抱很适合用于这样的代码。 runghc不是一个交互式解释器。 ghci是,也很好用。 – AndrewC