1
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)

BuyItemに渡さなければならない値は

buyItem currentStockBase "Akon" 20

でも「エイコン」をアートに送りたいし、20年はnumを送りたい

それは私にこのエラーを与えます

ERROR file:.\Project2.hs:126 - Type error in application
*** Expression     : buyItem currentStockBase art num
*** Term           : num
*** Type           : [Char]
*** Does not match : Int

私を助けてください

4

2 に答える 2

5

numですStringbuyItemを期待していIntます。たとえば、を使用して、文字列を Int に変換する必要がありますread

buyItem currentStockBase art (read num)

編集:String意味[Char]--- うまくいけば、これはエラーメッセージがより意味のあるものになることを意味します。

于 2010-03-18T11:59:51.760 に答える
2

num が文字列だからですか?で解析してみてくださいread

let test= buyItem currentStockBase art (read num)
于 2010-03-18T11:59:15.730 に答える