Nub*_*iya 1 io haskell interactive
putStrLn "Enter the Artist Name"
art <- getLine
putStrLn "Enter the Number of CD's"
num <- getLine
let test= buyItem currentStockBase art num
printListIO (showcurrentList test)
Run Code Online (Sandbox Code Playgroud)
我必须为buyItem传递的值是
buyItem currentStockBase "Akon" 20
Run Code Online (Sandbox Code Playgroud)
但我想发送"Akon"到艺术和20我想发送num
它给了我这个错误
ERROR file:.\Project2.hs:126 - Type error in application
*** Expression : buyItem currentStockBase art num
*** Term : num
*** Type : [Char]
*** Does not match : Int
Run Code Online (Sandbox Code Playgroud)
请帮我
num是一个String.buyItem期待一个Int.您需要将String转换为Int,例如使用read.
buyItem currentStockBase art (read num)
Run Code Online (Sandbox Code Playgroud)
编辑:String意味着[Char]---希望这意味着错误信息现在对你更有意义.