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)

the values i have to pass for buyItem is

buyItem currentStockBase "Akon" 20

but i want to send "Akon" to art and for 20 i want to send num

it gives me this error

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

please help me

1

2 Answers 2

5

num is a String. buyItem is expecting an Int. You need to convert the String into an Int, for example by using read.

buyItem currentStockBase art (read num)

Edit: String means [Char] --- hopefully this means the error message makes more sense to you now.

Sign up to request clarification or add additional context in comments.

Comments

2

Is it because num is a string? Try parsing it with read:

let test= buyItem currentStockBase art (read num)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.