I am new to Haskell programming, I have a requirement to print the grades based on the marks using Guard. Please find below code.
Any help would be appreciate as I am getting compiler error.
Couldn't match expected type ‘Integer -> String’
with actual type ‘[Char]’
• In the expression: "MediumPass"
In an equation for ‘printMarks’:
printMarks mark
| mark >= 50 && mark <= 59 = "MediumPass"
| mark >= 60 && mark <= 69 = "High Pass"
| mark >= 80 && mark <= 100 = "Distinction"
| otherwise = error "invalid mark"
The code:
printMarks :: Integer -> Integer -> String
printMarks mark | mark >= 50 && mark <= 59 = "MediumPass"
| mark >= 60 && mark <= 69 = "High Pass"
| mark >= 80 && mark <= 100 = "Distinction"
| otherwise = error "invalid mark"
main = do
putStrLn "Printing Grade"
print(printMarks 51)